A new way of doing reflection with .NET 8 #78
Replies: 6 comments 6 replies
-
|
Just a minor typo in: GetCountField(counter) = 100); |
Beta Was this translation helpful? Give feedback.
-
|
looks promising - much cleaner than the reflection chain. |
Beta Was this translation helpful? Give feedback.
-
|
How would one define these methods against types that are private or internal to assemblies not in our control? I would say that's the most common use-case for reflection for me. |
Beta Was this translation helpful? Give feedback.
-
|
Maybe I'm missing the point, but "old way" makes it possible to defer the choice of what property/field to access at runtime, while the "new one" requires moving such choice at build-time. Shouldn't reflection be a way to write late-binding code? |
Beta Was this translation helpful? Give feedback.
-
|
Usually there be demons when using types whose names start with "Unsafe". |
Beta Was this translation helpful? Give feedback.
-
|
So reflection lets you access a private variable from outside the Counter class, and alter this variable, which is supposed to be readonly. This seems to me a huge design/security flaw. I mean, what good is encapsulation if anyone can access a hidden variable? What good is readonly if anyone can alter its value? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
A new way of doing reflection with .NET 8
.NET 8 introduced a new way of doing reflection. Why did they introduce this, and what are some benefits - this blog post will give you some insights.
https://steven-giesel.com/blogPost/05ecdd16-8dc4-490f-b1cf-780c994346a4
Beta Was this translation helpful? Give feedback.
All reactions