Every New Feature Added in C# 12

  Рет қаралды 146,270

Nick Chapsas

Nick Chapsas

6 ай бұрын

Use code EF20 and get 20% off the brand new "Entity Framework Core in .NET" course on Dometrain: dometrain.com/course/from-zer...
Use code GRPC20 and get 20% off the brand new "gRPC in .NET" course on Dometrain: dometrain.com/course/from-zer...
Get the source code: mailchi.mp/dometrain/wuaizkh8ii
Become a Patreon and get special perks: / nickchapsas
Hello everybody, I'm Nick, and in this video, I will showcase every single feature added in C# 12 with examples. I've already talked about many of these features in detail and if you want in depth videos on any of them, you can find that in the following playlist: • C# 12 & .NET 8
Workshops: bit.ly/nickworkshops
Don't forget to comment, like and subscribe :)
Social Media:
Follow me on GitHub: github.com/Elfocrash
Follow me on Twitter: / nickchapsas
Connect on LinkedIn: / nick-chapsas
Keep coding merch: keepcoding.shop
#csharp #dotnet

Пікірлер: 252
@AgentFire0
@AgentFire0 6 ай бұрын
a comment down below.
@byathaiahbyathaiah1923
@byathaiahbyathaiah1923 6 ай бұрын
😅😅.😅 1:39
@TurntableTV
@TurntableTV 6 ай бұрын
So glad they simplified the way you create arrays.
@qub1n
@qub1n 6 ай бұрын
Finally I got PHP like arrays!
@modernkennnern
@modernkennnern 6 ай бұрын
Not having a target type is very annoying though, but it's prioritized for C# 13 so hopefully we'll get it sooner rather than later 😃
@1987RX7TII
@1987RX7TII 6 ай бұрын
Yeah literally yesterday I tried to assign value to an int[] property in a constructor of an extension class for a pagination view model and the compiler did not like PageSizes = {10, 20, 50}; Until I did “new int[] {10, 20, 50};” and I thought it was dumb. Quite happy it’s going to work now if I use square brackets.
@maschyt
@maschyt 6 ай бұрын
You could already do int[] array = { 1, 2, 3 };
@anilpillay2193
@anilpillay2193 5 ай бұрын
Nice python style
@kochendorfer6433
@kochendorfer6433 6 ай бұрын
int[] values = { 1, 2, 3, 4, 5 }; has been around since 2001 as array initialization syntax, but now you can replace the {} by []. So that's pretty cool ^^.
@tore28
@tore28 6 ай бұрын
it is similar to Python which can infer the type also. It looks like they are trying to add more syntactic sugar to make c# a more compact language, in your case, it is the same number of chars but using square brackets consistently is nice
@DevonLehmanJ
@DevonLehmanJ 6 ай бұрын
First version in years that I'm not super excited to upgrade. I will be upgrading ASAP anyway. My biggest would be primary constructors, if I could specify them as read-only. Then I could remove a ton of boilerplate dependency injection constructors
@Meryovi
@Meryovi 6 ай бұрын
Not being able to mark params as readonly is a bummer.
@vivekkaushik9508
@vivekkaushik9508 6 ай бұрын
Exactly my thoughts
@AgentFire0
@AgentFire0 6 ай бұрын
@@Meryovi another bummer is that they do not automagically convert into get-only properties as in records. But then again, maybe it's time to convert our services to record types lol
@apokislyuk
@apokislyuk 6 ай бұрын
I thought i understood primary constructors and didn't like them as well, but it's actually more flexible the way they are, if needed readonly: class MyDataService(OtherService otherService) { private readonly OtherService otherService = otherService ?? throw new ArgumentNullException(nameof(otherService)); As you see, not only readonly, but also checked for nulls just in case, and all as part of field initializers. I find it useful to simplify dependency injection, I think Nick didn't cover this point enough.
@Nk54fr
@Nk54fr 6 ай бұрын
​@@apokislyuknice way to do it
@Misteribel
@Misteribel 6 ай бұрын
As happens quite often, some features were taken from F#, where they've been part of the lang for a long time. I.e.: primary constructors, collection expressions, type aliases. Inline arrays are cool, they were part of MSIL for some time, but you couldn't easily use it.
@true_xander
@true_xander 6 ай бұрын
And still, no language is even close to Rust in terms of declaring collections. It is so much easier and more flexible!
@zeckul
@zeckul 5 ай бұрын
Type aliases are way more useful in F# as they are available across the project as a real type instead of acting as a local alias only.
@celiacasanovas4164
@celiacasanovas4164 6 ай бұрын
Awesome video, thank you! I greatly appreciate the quality of life features and I'm sure libraries and code generators will make good use of the other features. I wonder if it's going to be practical to actually use inline arrays or if just using Spans is going to be enough for most of us. Looking forward to default constructors and collection expressions getting fully fleshed out in C#13 and 14.
@gctypo2838
@gctypo2838 6 ай бұрын
Overall this lang version seems a lot less interesting compared to the past 3 versions. Alias any type seems kinda neat, though it's unlikely I'll use it. Primary constructors have a weird implementation and I'm hesitant to treat them as safely usable in comparison to how they work in records. Interceptors are conceptually interesting, but I fear the code some hotshot programmer might write thinking they're clever trying to use a feature intended only for source generators. Collection expressions seem real nice though, easily the most useful thing on the list. C# 8-11 were pretty interesting, adding using declaration statements, switch expressions, explicitly nullable reference types, records, advanced pattern matching, and all sorts of game-changing features. Not really seeing that this time around. Still annoyed we don't have language-level union types or readonly locals yet.
@InfinityFnatic
@InfinityFnatic 6 ай бұрын
Please do a video on .NET 8 Minimal API Native AOT on AWS lambda, using a database. There were a lot of improvements in that area compared to .NET 7. Thanks!
@CrapE_DM
@CrapE_DM 6 ай бұрын
[ ] are square brackets. < > are angle brackets
@nickst0ne
@nickst0ne 6 ай бұрын
PrimaryConstructors => look like a poorly-controlled properties with public setters. CollectionExpressions => cool stuff. Interceptors => Beyond mocks, I don't see what new opportunities they offer. All the rest => probably won't use, but thanks for keeping us up to date. 🙏
@TonyChuPT
@TonyChuPT 6 ай бұрын
Interceptors could be very helpful for inserting log messages to where-ever necessary but without actually changing the code being intercepted, and you can easily remove the interceptor code later when logging messages are to be removed, once again no need to change the intercepted code. As for how to specify the InterceptsLocation attribute with accurate file path / line / column info, I guess it would need some smart preprocessing code, but that still seems doable.
@proosee
@proosee 6 ай бұрын
Interceptors basically allow you to do what only PostSharp can do without making changes on compiled code (the way PostSharp is doing this), so, imagine nuget, that will generate interceptors which will decorate your code with logging/caching/change tracking and so on by just simply adding one attribute to property/method/class. That's just easier way to do such things than modifying IL. It is also cleaner way of doing this because the code is there and you can debug it easily. But, again, this not for 99% of developers, this is for small percentage of devs who develop cool tooling libraries. Primary constructors are only syntactic sugar and while I get they tried to achieve the same thing e.g. Typescript has, although I prefer the Typescript way actually.
@dukefleed9525
@dukefleed9525 6 ай бұрын
I agree that in this form interceptors are useful but on niche scenarios, probably are design this way to avoid to abuse of them, anyway, file path, line and column.... looks VERY ugly to my eyes, do someone knows if the path can be at least relative? I don't want to check in code that works differently when someone clone it in a different path
@proosee
@proosee 6 ай бұрын
@@dukefleed9525 why would you even ever manually write an interceptor? They are ugly because they can be - they will be always generated in some way or another, there is no reason to write them manually because if you can write something like that manually then why don't you just edit your method directly?
@modernkennnern
@modernkennnern 6 ай бұрын
Primary constructors are private fields, not public properties. What do you mean?
@ConstancyCAE
@ConstancyCAE 6 ай бұрын
Empty what? 🤣🤣
@Subjective0
@Subjective0 6 ай бұрын
Seems to me most og the “features” we will get are performance improvements, and I’m totally fine with that, as all the frameworks are getting new and nice stuff
@klocugh12
@klocugh12 6 ай бұрын
Guess it's time to start naming my dictionaries Richard 😂 Imagine saying out loud "an API consumes a dic"😂
@RobinHood70
@RobinHood70 6 ай бұрын
Use "dict" and make sure you pronounce that t. It's like "pianist" that way. 😉
@abhigupta3193
@abhigupta3193 27 күн бұрын
😂😂
@michawhite7613
@michawhite7613 6 ай бұрын
I died inside when I realized that for Interceptors, you have to specify the line number
@rex.mingla
@rex.mingla 6 ай бұрын
Even the file path literal seems clunky. What happens if devs don’t have the same base path? Maybe there is some relative path option for it.
@DemoBytom
@DemoBytom 6 ай бұрын
​@@rex.minglaInterceptors are supposed to work with source generators. Devs should never have to write it by hand. Source generators are run during compilation and will generate code based on the one that's being compiled, so the difference between machines won't matter - the in-memory generated code will be slightly different for each dev (different paths for example), but the compiled code will be the same - the new method will be called, instead of old one. It's basically a feature that wants to replace reflection. Reflection is not only slow, but also only evaluated during runtime. Interceptors will be evaluated during compilation, and produce a runnable, already "rewritten" method call.
@AlexBroitman
@AlexBroitman 6 ай бұрын
As I understand, Code Generator + Interceptor will give us real AOP, so I will be able to remove PostSharp.
@user-qp8bt7gq4b
@user-qp8bt7gq4b 6 ай бұрын
Thanks for the video, very simple and useful. As for me, primary constructors are game-changer, but I don’t like it at all. I believe they add some readonly keyword for parameter in C#13. Because with current implementation you simply cannot replace private readonly fields with constructor parameters and restrict their re-assignment. Collection Expressions - okay, cool, but it’s a pretty little change, so WHY is it cut??? I mean no support for Dictionary. Interceptors are something for library developers, not for regular web devs I think. Btw I waited the ‘field’ keyword for properties. To validate setter without manual creating of a backing field. And discriminated unions, of course. Feels like the whole community is just waiting for them.
@jonwilson7871
@jonwilson7871 6 ай бұрын
With DU, C# will enter the next echelon. Looking forward to it!!!
@renynzea
@renynzea 6 ай бұрын
I could see the alias feature being useful to pass around a tuple easier inside a class. Interceptors as well for test scenarios where there are no interfaces for the methods and it would be time consuming to refactor legacy code. But neither of those would push me to c# 12.
@user-tk2jy8xr8b
@user-tk2jy8xr8b 6 ай бұрын
Still no `using IntDict = Dictionary` :(
@kochendorfer6433
@kochendorfer6433 6 ай бұрын
Interceptors should be extended to something that can be configurably invoked OnEnterMethod and OnExitMethod (sometimes useful for logging performance or tracing hard-to-.find bugs) and then can be disabled, when the issue is fixed.
@vonn9737
@vonn9737 6 ай бұрын
Interceptors look like they could be useful for unit testing, although would be a pain to have to specify file, line and char pos.
@henningerhenningstone691
@henningerhenningstone691 6 ай бұрын
Yeah I hope they will revise that again before considering it done. Right now it looks more like a half-arsed text replacement instruction to the compiler rather than proper interceptors
@Dimitris.Christoforidis
@Dimitris.Christoforidis 5 ай бұрын
Thank you Nick for your wonderful videos. Is it possible to set attributes using record?
@sergeyiliushchenko5298
@sergeyiliushchenko5298 3 ай бұрын
Thanks buddy! You're doing a good job.
@brokiemydog
@brokiemydog 6 ай бұрын
Hey! Please make more video like this! I really liked it!
@the-niker
@the-niker 6 ай бұрын
Saw no joke in the HelloWorld template and thought Nick is slipping. Then I watched the rest of the video :D
@nickchapsas
@nickchapsas 6 ай бұрын
Oh SHIT I forgot! I did meet my 6,9 quota though
@purplepixeleater
@purplepixeleater 6 ай бұрын
lol I'm using ref readonly due to interop code with c++ and its been amazing to help fight accidentally corrupting memory through that process.
@PolishchukMaxim
@PolishchukMaxim 6 ай бұрын
Hey, you said about "void Test(ref readonly int age)" and "void Test(in int age)" - it is OK. But I think in order to understand difference between "ref readonly" and "in", you should say couple of words about "ref readonly int GetAge()". IMHO )))
@dienvidbriedis1184
@dienvidbriedis1184 6 ай бұрын
Year 2030, now you can use C# compiler to compile Scala code.
@JoseRodriguez-xu1jz
@JoseRodriguez-xu1jz 6 ай бұрын
What's the shortcut you used in 13:33 to increase the window size?
@--Eric--
@--Eric-- 6 ай бұрын
Ctrl + middle scroll
@ryan-heath
@ryan-heath 6 ай бұрын
Primary ctors and collection expressions are ones I like and will be using a lot. The alias is at a note-worthy second place. For the other features I don't see an immedaite use case.
@christianbay7614
@christianbay7614 6 ай бұрын
Going to use all the features here except Primary Constructors and interceptors. Though interceptors are also very interesting but they need to come out of experimental before we can use them.
@user-we6wp1ky7f
@user-we6wp1ky7f 6 ай бұрын
As my fullstack colleague said, c# looks at the typescript and try to grab some features from it. But not so fast as someone want.
@JoeIrizarry88
@JoeIrizarry88 26 күн бұрын
Looking forward to the libraries built by interceptors! For my use, most likely collection initializers.
@frossen123
@frossen123 6 ай бұрын
This these last years Microsoft seems to be enabling themselves to make everything blazing fast and aot friendly so we can all run all our code extremely efficiently on arm server and laptops soon. Did they do anything to improve the experience of writing source generators? i find usecases for it very often, but it's often a bit crappy to work with, especially if you build and use it in the same solution.
@AlFasGD
@AlFasGD 6 ай бұрын
I always love initializing my DICtionary
@badwolf01
@badwolf01 6 ай бұрын
Collection expressions. IDK how I feel about primary constructors. As far as many of the features being Microsoft-centric, they presumably make things better or more performant, so I'm all for them. I'd rather know about them then for them to be hidden.
@Matlauk
@Matlauk 6 ай бұрын
I wish that we had struct type collections. I have an instance where I need to do a deep copy on a structure of collections because the data needs to be transformed by multiple users and then merged back into a single structure.
@celiacasanovas4164
@celiacasanovas4164 6 ай бұрын
you can stackalloc arrays into Spans though!
@yeahdima
@yeahdima 6 ай бұрын
The general "we" won't be using most of this features, but like you mentioned yourself: library authors besides Microsoft itself can use it now. That way we don't depend on the wits of Microsoft alone to get stuff which is possible with these features.
@gabrielhalvonik192
@gabrielhalvonik192 6 ай бұрын
Another cut of semi-auto properties (field keyword) is really shame.
@anm3037
@anm3037 6 ай бұрын
They have been advertising it since two years ago but not releasing it ... sad
@celiacasanovas4164
@celiacasanovas4164 6 ай бұрын
they said they were wary of introducing a change that would break the code of the few developers who might have named a field "field". someone from the c# team said they were going to move ahead with it but provide a migration tool and they couldn't get it ready in time, partly because they had been considering several options
@WillHausman
@WillHausman 6 ай бұрын
If I'm understanding this correctly, interceptors could be used by testing libraries to source generate efficient mocks for concrete types and maybe even extension methods?
@gctypo2838
@gctypo2838 6 ай бұрын
Interceptors are for source generators, and source generators only. No sane programmer should write them manually in their codebases, otherwise it's a massive footgun.
@proosee
@proosee 6 ай бұрын
@@gctypo2838 exactly. I've seen some people complaining they look ugly with those line and column syntax - for me this is even better: if they gonna break after every little change then no one would use them in purpose of manually modifying method. I mean, I don't know who would want to even do that when you can edit your method directly, but I'm glad that syntax is even more discouraging...
@alehkhantsevich113
@alehkhantsevich113 6 ай бұрын
For me C# 12 brings only 2 good features: Collection Expressions and default lambda parameters. I know many ppl think that Primary Constructors are good one. But for me personally I don't like them at all. The reason is that it breaks naming conventions. I like the fact when I see _smthing it's private field of the class when reading code 200 lines below constructor declaration and if something without underscores - it's method argument or local variable.
@diadetediotedio6918
@diadetediotedio6918 6 ай бұрын
Well, you still have the option of not using them at all if you like this weird naming convention of using underscores. And you can also name your params with _ in the primary constructors.
@alehkhantsevich113
@alehkhantsevich113 6 ай бұрын
The only weird thing about this is your comment. I wrote the real reason why underscore makes sense.
@diadetediotedio6918
@diadetediotedio6918 6 ай бұрын
@@alehkhantsevich113 I didn't said your explanation was wrong or bad, or that underscores did not make sense. I said they were weird (and for me, kinda annoying), and I don't like using them in general (and I really never perceived any more difficulty in just using only just the name). For me, most of the time you will not need to make these differentiations, you can get it working pretty well by just using camelCase for fields and PascalCase for properties, and when you are in a constructor you just this., it works and it is not weird.
@ryan-heath
@ryan-heath 6 ай бұрын
For me it is a welcome change, I didn't like the _smthing since we have dropped the m_smthing already in an earlier phase. (coming from c++, yep I'm old cat 😅). The compiler will warn you if you have a local or class parameter clash. I strongly believe the _smthing only stayed, because people didn't like to use this.smthing in the c'tor init stage ... Also, side note: if you cannot make up what a variable is, then perhaps your class is doing too much and is too big.
@alehkhantsevich113
@alehkhantsevich113 6 ай бұрын
​@@diadetediotedio6918 Yes, I apologize for the rude previous reply. I basically agree that it is possible to write this way. But for me, separating private and local makes sense. Looking through the code, I instantly see when other services are called (since they are usually from DI and therefore private with underscore). In general, I like the idea of Primary Constructors, but for me it makes the code harder to read. So, I'll most likely do this: public class SomeClass(ISomeService someService, IAnotherService anotherService) { private readonly _someService = someService; private readonly _anotherService = anotherService; } This does not remove the entire boilerplate, but it does not violate the conventions.
@Solares91
@Solares91 6 ай бұрын
Regarding interceptors so this is mostly for people who have access to source code but don't want to edit it directly but they want to alternate it only for some specific cases that they uses?
@killymxi
@killymxi 6 ай бұрын
Alias any type but not generics yet, if I understand correctly. Generics was one of the first things I was looking to alias at some point. One step at a time, I guess.
@andriikomisarenko7785
@andriikomisarenko7785 5 ай бұрын
How interceptors with file location will stores in git?
@rubananderson3880
@rubananderson3880 6 ай бұрын
for primary constructors that'd be great if we could have a syntax like public class myclass (readonly ParamType1 param1, readonly ParamType2 param2) { init {some init code} // class stuff}
@FizWiz91
@FizWiz91 6 ай бұрын
I think the new collection syntax, aliasing and the spread operators are the features I'll be using the most in the near future
@Zullfix
@Zullfix 6 ай бұрын
Were UnsafeAccessors cut from .NET 8? I was really looking forward to what seemed to be essentially NativeAOT reflection.
@nickchapsas
@nickchapsas 6 ай бұрын
From what I understand, that's not listed because it's a .NET feature not a C# feature, but I could be wrong
@tommyzemich5412
@tommyzemich5412 6 ай бұрын
5:00 deserves an extra like. 🤣
@vincentanzelone8705
@vincentanzelone8705 6 ай бұрын
Awesome video but I don't think I am going to use any of those LOL. Love your videos though. Thanks for all of the awesome content.
@a__random__person
@a__random__person 6 ай бұрын
Interceptor is just crazy, lol idk why they are releasing that.. so much potential for abuse.. let alone enormous debugging headaches for those who don't know it's being used!
@proosee
@proosee 6 ай бұрын
Abuse how?
@modernkennnern
@modernkennnern 6 ай бұрын
Rider just released support for interceptors this week to highlight lines being intercepted
@a__random__person
@a__random__person 6 ай бұрын
@@prooseelike using a 3rd party library and intercepting code to change the behavior. Or being the 3rd party library, and knowing your consumers use other common 3rd party libraries and changing their behavior. Imagine if newtonsoft.json intercepted code from spotify to send credit card details to an additional server lol. There's hopefully guardrails to prevent this kind of thing.
@buddy.abc123
@buddy.abc123 6 ай бұрын
Awesome!
@lordmetzgermeister
@lordmetzgermeister 6 ай бұрын
Not that many lifechanging features, well it's an LTS version so it makes sense. Feels more like they had to release something so they just used their internal features.
@McZsh
@McZsh 6 ай бұрын
C# finally catching up with VB.NETs collection literals... but no var allowed, while a dynamic Dim in VB works just fine.
@girish9841
@girish9841 5 ай бұрын
Awesome 👌
@B1aQQ
@B1aQQ 6 ай бұрын
What if I have 2 interceptors pointing at the same place? Is there a collision avoidance mechanism? Can it be either of them?
@TonyChuPT
@TonyChuPT 6 ай бұрын
I'm guessing the first interceptor overwrites the code being intercepted, then the second interceptor overwrites it again so the second one actually takes the precedence. If this is true, then the whole interceptor mechanism will depend on the order of your codes being compiled. That could be a potential "interceptor hell".
@modernkennnern
@modernkennnern 6 ай бұрын
Compiler error
@marcusmajarra
@marcusmajarra 6 ай бұрын
I think that the only new feature I actually dislike are primary constructors. Interceptors can be a great addition for libraries that want to add compile-time AOP functionality to an existing codebase.
@maschyt
@maschyt 6 ай бұрын
I think primary constructors are a great way to reduce boilerplate code for dependency injection. Because for every service you inject you needed to declare a field, declare a constructor argument and assign the argument to the field. Now you only need to declare the service in the primary constructor and you are done. So you reduce the code lines to one third, which may really increase readability the more services you need to inject.
@marcusmajarra
@marcusmajarra 6 ай бұрын
@@maschyt I would agree with you if the generated fields were read-only and enforced non-null constraints. As they are, I don't find them convenient at all. I don't find that this adds anything to the readability since you're not actually clarifying anything for the developer andare instead relying on compiler magic that doesn't make the dependencies apparent as actual dependencies. Instead, what you get is a reduced initialization list for mutable members.
@diadetediotedio6918
@diadetediotedio6918 6 ай бұрын
I want to develop some optimizations for .NET using the interceptors
@Kaalund1989
@Kaalund1989 6 ай бұрын
can i intercept a method that i have a attribute on and wrap it in a transaction and then do the original method ?
@tymurgubayev4840
@tymurgubayev4840 6 ай бұрын
yes
@tassisto
@tassisto 6 ай бұрын
new Dic 😂😂😂 You’re awesome
@weizhen77
@weizhen77 6 ай бұрын
Any performance improvements as compared to .NET 6 and .NET7?
@baranacikgoz
@baranacikgoz 6 ай бұрын
I always wanted primary constructors like many languages did, finally it arrived
@tore28
@tore28 6 ай бұрын
Defining a type via using, it is perhaps similar to typedefs in other languages. Not sure if using defining a new type is a good thing. But sometimes you need a small class but dont want to declare it in an own file and having a possibility to straight up define a tuple combination for example as a type is handy.
@henningerhenningstone691
@henningerhenningstone691 6 ай бұрын
That's what I was thinking, gets us one step closer to typedefs. Still far from it though...
@nik6823
@nik6823 2 ай бұрын
what do you think the use of interceptors are? cant people just make virtual methods instead?
@sp00l
@sp00l 6 ай бұрын
I wounded if the interceptor could be used to create some interesting ways to prevent data manipulation for hacking in games
@dlwiii3
@dlwiii3 6 ай бұрын
Darn when I saw interceptors I thought it would be like Castle Proxy which I love.
@FireDragon91245
@FireDragon91245 6 ай бұрын
Nicest feature array expressions
@Myricaulus
@Myricaulus 6 ай бұрын
chapters would fit this video very good
@Kingside88
@Kingside88 6 ай бұрын
Great video, thank you! In my opinion, C# is a perfect language for write applications you like. Most of the features are nice to have only. So I don't know if I miss something in C# but on the other hand microsoft improve some little thinks to create a world where people knowing other languages can fast adapt to C#. Great work Microsoft
@5cover
@5cover 6 ай бұрын
I wish they would implement semi-auto properties... my view models are cluttered with explicit backing fields since i must call OnPropertyChanged on the setter of public properties
@BittermanAndy
@BittermanAndy 6 ай бұрын
CollectionExpressions somewhat nice, but I prefer using var so probably won't use these. Nothing else here I'm likely to use.
@patfre
@patfre 6 ай бұрын
I use var a lot too but there are a lot of places in my code where I can drop it like a method returning the value of a switch statement there I just had a thing today where I can remove the old array syntax which is nice. The AliasAnyType arguably one of the most anticipated feature for me personally.
@dvldev
@dvldev 6 ай бұрын
Interceptors are most exciting feature I think. I didn't notice that they put primary constructors like Kotlin. But why they don't copy full potential of this? :P
@sironjuh
@sironjuh 6 ай бұрын
To me the current implementation seems so clunky that if you try to keep it working in evolving codebase, you spend more time hunting rows and characters than doing anything useful. It would be nice if it worked just marking the class and the method to intercept instead of manually trying to keep up with the changes.
@celiacasanovas4164
@celiacasanovas4164 6 ай бұрын
They're thinking about it but couldn't find a solution they liked yet.
@dvldev
@dvldev 6 ай бұрын
I mean why they don't merge class and records. Records behind the scene creates public properties and just add curly braces to add functions. Besicly they have to extend the records 😜 Anyway.
@thomashamilton564
@thomashamilton564 6 ай бұрын
Interceptors looks like some new GOTO hell.
@arianmdq
@arianmdq 6 ай бұрын
I would like to use the interceptors but without specifying the line and the path... maybe something like using the name of the class and the method that contains that call or something like that. It's very very risky to have these kind of "hardcoded" lines.
@GumbootMan
@GumbootMan 6 ай бұрын
It's not risky if you only use the interceptors feature from a source generator, as intended by the designers of the feature.
@killymxi
@killymxi 6 ай бұрын
I suspect someone will write a source generator for that soon after release...
@chairmakerPete
@chairmakerPete 6 ай бұрын
Nothing I'll use, but good to see development of the language continues apace
@RubenALopes
@RubenALopes 6 ай бұрын
New *D I C* ...tionary 😂
@saniel2748
@saniel2748 6 ай бұрын
I don't understand what's the big idea behind inline arrays syntax instead of just allowing fixed int whatever[10] take any type instead of just primitives
@MaksMikhnevych
@MaksMikhnevych 6 ай бұрын
Interceptor feature is sick! However, I cannot find any application to it. Shrug
@blewskrin
@blewskrin 6 ай бұрын
Can one do an interceptor on another interceptor? :)
@IsraelQuiroz
@IsraelQuiroz 6 ай бұрын
i love that they just added interceptors from Angular haha
@fbsouza
@fbsouza 6 ай бұрын
I like the way you talk. Fast. Noice!
@wy97765
@wy97765 6 ай бұрын
4:53 😅
@robl39
@robl39 5 ай бұрын
“Hello everybody I’m naked”… I can’t unhear this 😂
@Neonalig
@Neonalig 6 ай бұрын
4:52 ...And this kids is why I call them 'dict' instead of 'dic'
@MaxIzrin
@MaxIzrin 6 ай бұрын
Initializing arrays is nice, and lambda default params is great! But the constructor, and the using declaration stuff feels terrible, just seems like a bug-ridden land-mine. Not knowing what "new" does isn't a good thing, in my opinion.
@diadetediotedio6918
@diadetediotedio6918 6 ай бұрын
But you surely know what 'new' does, it is not masked. The usings are very transparent
@modernkennnern
@modernkennnern 6 ай бұрын
The using declarative change was for all intents and purposes a bug fix to the language
@MaxIzrin
@MaxIzrin 6 ай бұрын
@@modernkennnern How so? I don't understand what you mean by that.
@modernkennnern
@modernkennnern 6 ай бұрын
@@MaxIzrin you've always been able to do "using X = Y" on most types, but for a few set of types - like for example ValueTuples as illustrated in this video - you couldn't. C# 12 patches that hole in the language specification, simplifying it.
@MaxIzrin
@MaxIzrin 6 ай бұрын
@@modernkennnern I didn't know that existed. using X = Y seems sloppy to me.
@shahzaibhassan2777
@shahzaibhassan2777 6 ай бұрын
That dict-tionary sounding like something else, is relatable 😂
@krccmsitp2884
@krccmsitp2884 6 ай бұрын
Primary constructors actually make a lot of sense when used for DI, saving a lot of unnecessary boilerplate code.
@user-qp8bt7gq4b
@user-qp8bt7gq4b 6 ай бұрын
But. Only if they would be readonly. They are not, so you simply CAN’T provide the same functionality. You can only remove boilerplate by making your code unsafe.
@apokislyuk
@apokislyuk 6 ай бұрын
@@user-qp8bt7gq4b Here is the way you do it readonly: class MyDataService(OtherService otherService) { private readonly OtherService otherService = otherService; and not only readonly, you can do anything you like as part of field initializers, e.g. checking for null or providing default value, or resolving actual value from a factory parameter: class MyDataService(OtherService otherService) { private readonly OtherService otherService = otherService ?? throw new ArgumentNullException(nameof(otherService)); You can set any visibility or define as a property. You can also use any field name conventions, e,g. _otherService.. Honestly, i see it is much better than trying to put in on a single line as part of the parameter.
@aathifmahir
@aathifmahir 6 ай бұрын
Collection Literals and Primary Ctors
@tamasdeli1759
@tamasdeli1759 3 ай бұрын
I think the primary ctor is realy usefull.
@maacpiash
@maacpiash 6 ай бұрын
New feature request for C# 13 on behalf of Nick Chapsas: spread operator for keywords. Example: `Dic…tionary`
@rodnyjoseph3492
@rodnyjoseph3492 6 ай бұрын
Microsoft was like, "Yeah we need this so we added it and made it public. Do you want to use it too? No? Okay well it's here if you change your mind" lol
@jkc6144
@jkc6144 2 ай бұрын
@Fenwryches
@Fenwryches 6 ай бұрын
You are like that because you are amazing 😁
@maksimprudnikau4630
@maksimprudnikau4630 6 ай бұрын
С# is becoming typescript
@khorsfb
@khorsfb 6 ай бұрын
nice
@logank.70
@logank.70 6 ай бұрын
"Because value types are copied by default." Isn't it true that everything is pass by value (by default) regardless of it being a struct or a reference type? For structs it copies the data and for references it does the same thing it just so happens that the value is the reference. Is that accurate?
@mbenoni7397
@mbenoni7397 6 ай бұрын
yes
@nickchapsas
@nickchapsas 6 ай бұрын
Yeah but when we say that the value is copied we referred to the actual object not the reference
6 ай бұрын
I see the struggle of moving from Rider to VS 😬
@BenMakesGames
@BenMakesGames 6 ай бұрын
I have mixed feelings about the new primary constructors. I would have preferred TypeScript's "parameter properties", where you write a constructor like `constructor(private readonly name: string)`, which in C# might have looked something like `public Person(private readonly string Name)`.
@proosee
@proosee 6 ай бұрын
I have two words for C# language developers: discriminated unions. Although, those features are pretty neat.
@celiacasanovas4164
@celiacasanovas4164 6 ай бұрын
they're taking so long they might as well go straight for GADTs
@KasperDahlTangen
@KasperDahlTangen 6 ай бұрын
Would be cool with Dictionary and HashSet expressions (like in python) also
@KasperDahlTangen
@KasperDahlTangen 6 ай бұрын
And would be nice if collection expreession would be interpreted automaticly as a list if the type is not specified rather than getting a conpiletime error
@KasperDahlTangen
@KasperDahlTangen 6 ай бұрын
And a spread operation for anonymous types. And the ability for anonymous types to inherit interfaces
@KasperDahlTangen
@KasperDahlTangen 6 ай бұрын
F*** it. Spread and interfaces for touples also. Interopability between anonymous classes and touples and defined types/interfaces. And Funcs and Actions can be used to mimic methods an interface or defined type expects
@modernkennnern
@modernkennnern 6 ай бұрын
@@KasperDahlTangen why limit it to lists always. Needless heap allocations. They chose to delay natural types in order for improved performance later. Let's say you create a collection and only use it in that method; you'd get improved performance by using a span instead of a list in that context.
@KasperDahlTangen
@KasperDahlTangen 6 ай бұрын
@@modernkennnern I’m not quite sure if I understood your question. All I meant in the second comment was that { var collection = [1,2,3] } shouldn’t give you a compile time error, and rather interpret it as { List collection = [1,2,3] } implicitly under the hood. In that sense you should still be able to explicitly write { Span collection = [1,2,3] } for instance without any issues
@JackBauerDev
@JackBauerDev 6 ай бұрын
Man there is a lot of ways to do the same thing, this is gonna confuse a lot of junior and senior devs!
@goodoleme747
@goodoleme747 5 ай бұрын
All is great…except primary constructors.
@UgrevsBoots
@UgrevsBoots 6 ай бұрын
I snorted my coffee.. son of a.. hahah
The C# 12 Feature You Shouldn’t Use, Yet
10:07
Nick Chapsas
Рет қаралды 33 М.
Measure Your Application’s Performance in .NET
12:41
Nick Chapsas
Рет қаралды 33 М.
ISSEI funny story😂😂😂Strange World | Magic Lips💋
00:36
ISSEI / いっせい
Рет қаралды 148 МЛН
I MADE A CARDBOARD SWING!#asmr
00:40
HAYATAKU はやたく
Рет қаралды 32 МЛН
I PEELED OFF THE CARDBOARD WATERMELON!#asmr
00:56
HAYATAKU はやたく
Рет қаралды 35 МЛН
How do you make Linux more popular?
11:41
Surfshark Academy
Рет қаралды 23 М.
Getting Started with Event Sourcing in .NET
37:07
Nick Chapsas
Рет қаралды 18 М.
What are record types in C# and how they ACTUALLY work
15:36
Nick Chapsas
Рет қаралды 116 М.
The First Feature of C# 13 Is Here!
11:10
Nick Chapsas
Рет қаралды 56 М.
Why Startups Hate .NET and C#
10:38
Nick Chapsas
Рет қаралды 238 М.
The New Data Protection Features of .NET 8 (GDPR)
14:10
Nick Chapsas
Рет қаралды 47 М.
Why is C# Evolving This Way?
15:02
Zoran Horvat
Рет қаралды 19 М.
What's New in C# 8.0
12:56
Microsoft Visual Studio
Рет қаралды 299 М.
Make Your LINQ Up to 10x Faster!
11:08
Nick Chapsas
Рет қаралды 52 М.
ISSEI funny story😂😂😂Strange World | Magic Lips💋
00:36
ISSEI / いっせい
Рет қаралды 148 МЛН