Default for "var x = []" should be list. Never in my life have I wanted an easier way to create an empty array except when passing as a parameter. What would it's use case be?
That makes sense. But what about "var = [5]"? You could argue it should be an array. But then you get a list when it's empty and an array when it's not? That doesn't make sense.
Very valid point if consumers of the syntax are using it as a shorthand for existing types. Also Agreed that would be unexpected unless it’s defined behavior. Consider whether the compiler can infer the best type based on how it’s used in the same way it does when the left hand side is defined. If I mutate, give me the best mutable type. If I don’t, the best non-mutable. If I return it as a span, consider that. Or if I return an IEnumerable, please do the best there. When I see the syntax it kind of kicks me into a more dynamic context. We have anonymous objects, anonymous methods, lambda expressions which generate expression trees (not IL methods), and now we even have anonymous delegates with default parameters. Could this syntax be anonymous collections? Basically says “I don’t care about the underlying type, please use or create the best one that fulfills my needs based on local usage”. I say local because this syntax in a field or property wouldn’t work if it was anonymous and I think that’s ok.
@@jamesl5149 this isn't a visual studio talk maybe he should go in notepad. Wait this isn't a notepad talk... Tools are tools, it's a tool a lot of people use with C#, its related
@@alfflasymphonyxnot everyone uses visual studio and no one's crying that they're pushing VS? Not everyone is on windows, maybe we should ask them to program in notepad to make everyone happy?
@@modernkennnern property injection. You always had factory or strategies to construct your objects and stitch things together. Constructor injection to my mind simplifies things. And you can hold a reference to IServiceProvider to do other resolutions as you need them.
@@alexisfibonacci You can hold a reference to IServiceProvider but you almost never should. 🙂 Instead, you should pass in a more specific factory, if you can. Otherwise, it's no longer possible to see which types a type depends on -- it can create whatever it likes with the IServiceProvider. Sometimes you need this, like when you're instantiating plugins from a configuration but it's rare. To the OP, I don't know why constructor injection would be considered bad. It allows you to see a type's dependencies and reason about your code more easily. If a type has everything it will ever have when it's constructed, then there are far fewer code paths to consider. There are always exceptions, of course, but the general direction should be to inject simple types (i.e., not IServiceProvider) in the constructor ... and make properties read-only. 🙂
26:40 a docker container uses a system kernel and it uses system clock, so it wouldn't work anyways. you need a vm. or just run all tests in serial and modify system clock every time
what's the point of private fields in your can change their values via reflection. Getting a list of private fields, I'm ok with this but we should not be allowed to change their values.
Default for "var x = []" should be list. Never in my life have I wanted an easier way to create an empty array except when passing as a parameter. What would it's use case be?
That makes sense. But what about "var = [5]"? You could argue it should be an array. But then you get a list when it's empty and an array when it's not? That doesn't make sense.
Very valid point if consumers of the syntax are using it as a shorthand for existing types. Also Agreed that would be unexpected unless it’s defined behavior.
Consider whether the compiler can infer the best type based on how it’s used in the same way it does when the left hand side is defined.
If I mutate, give me the best mutable type. If I don’t, the best non-mutable. If I return it as a span, consider that. Or if I return an IEnumerable, please do the best there.
When I see the syntax it kind of kicks me into a more dynamic context. We have anonymous objects, anonymous methods, lambda expressions which generate expression trees (not IL methods), and now we even have anonymous delegates with default parameters.
Could this syntax be anonymous collections? Basically says “I don’t care about the underlying type, please use or create the best one that fulfills my needs based on local usage”. I say local because this syntax in a field or property wouldn’t work if it was anonymous and I think that’s ok.
Title is wrong, it's David Fowler, not Damian Fowler 😊
I like the idea they've done so many talks together they are just "Damian Fowler" now 😄
I hope “Scott Toub” becomes a thing.
Turn off copilot next time. Ruins the presentation
no it doesn't. It shows real life usage of copilot...
@@codder32this isn't a copilot talk
@@jamesl5149 this isn't a visual studio talk maybe he should go in notepad. Wait this isn't a notepad talk...
Tools are tools, it's a tool a lot of people use with C#, its related
@@codder32 not everyone uses Copliot
@@alfflasymphonyxnot everyone uses visual studio and no one's crying that they're pushing VS?
Not everyone is on windows, maybe we should ask them to program in notepad to make everyone happy?
anyone know what is the light theme he is using?
I'm old enough to remember when constructor injection was considered bad.
What was considered best practice at that point? Method parameter injection?
@@modernkennnern probably property injection. tons of cargo cult bad/good that doesn't really matter
@@modernkennnern property injection. You always had factory or strategies to construct your objects and stitch things together. Constructor injection to my mind simplifies things. And you can hold a reference to IServiceProvider to do other resolutions as you need them.
@@alexisfibonacci You can hold a reference to IServiceProvider but you almost never should. 🙂 Instead, you should pass in a more specific factory, if you can. Otherwise, it's no longer possible to see which types a type depends on -- it can create whatever it likes with the IServiceProvider. Sometimes you need this, like when you're instantiating plugins from a configuration but it's rare.
To the OP, I don't know why constructor injection would be considered bad. It allows you to see a type's dependencies and reason about your code more easily. If a type has everything it will ever have when it's constructed, then there are far fewer code paths to consider.
There are always exceptions, of course, but the general direction should be to inject simple types (i.e., not IServiceProvider) in the constructor ... and make properties read-only. 🙂
26:40 a docker container uses a system kernel and it uses system clock, so it wouldn't work anyways. you need a vm. or just run all tests in serial and modify system clock every time
what's the point of private fields in your can change their values via reflection.
Getting a list of private fields, I'm ok with this but we should not be allowed to change their values.
Hall Michael Thompson Deborah Thomas Betty
What's with all the silly noises?
Unwatchable.