C# Reflection Explained (Claim generation example)
ฝัง
- เผยแพร่เมื่อ 18 ต.ค. 2024
- In this c# reflection tutorial I try to answer questions like: what is reflection? how to use reflection? how to solve problems with reflection? Primarily I try to shift your perspective to looking at your code as just another source of data which we manipulate using reflection. We then go to implement a real world example, where we generate all possible claims we would need and authorize based on generated claims.
Patreon 🤝 / raw_coding
Courses 📚 learning.raw-c...
Shop 🛒 shop.raw-codin...
Discord 💬 / discord
Twitter 📣 / anton_t0shik
Twitch 🎥 / raw_coding
👉 Try Rider
www.jetbrains....
RD5K9-4TXXW-KMV3G-NYWSF-3ZSTP
Source: github.com/T0s...
#csharp
I miss dislike button
Like this comment to dislike
@@RawCoding simple explanation that worked for me is that reflection is just reading a section of metadata, which .NET adds to compiled assemblies
having this comment pinned is the real self-reflection
Thank you for sharing an explanation that clicked for you
subbed just cause you pinned this comment, a man with intellectual humility.
Thank you very much for the time and effort you put for people to learn. Obviously not a lot of people understand how hard it is to acquire the knowledge you have digested and shared to the community in such a great way. Again, thanks and keep up the awesome work!
Always wanted to take a closer look into reflection. I will take a look at the video later today, thanks for posting!
Hope it helps :)
Dude. That pad is Amazing. Scoping into classes looks very nice. Good job sharing that
Glad you like it!
Hi, Thanks Anton for all the awesome content on your channel. Which LinqPad extension did you use for ConvertTo() ? Also, how did you gain some much knowledge in C#? any recommendations ?
public static T ConvertTo(this string @this) => JsonSerializer.Deserialize(@this);
and just practice :)
@@RawCoding thanks dude
Amazing, I gel with your vibe. thanks dude. I appreciate it.
Awesome!
Dude, awesome video... One of that moments that resets your self-estimation as a programmer back to a first-grader
Haha yea I don’t think that ever stops
@@RawCoding for sure)
This was really eye opening for me. Thank you very much sir!
Thank you for watching))
This is so great!! I am going to add to watchlist to watch it again...
hi thank you for this but could you please make full tutorial on lamda, func, ,anonymous method and event
Sure :)
Ok that intro and that phrasing was literally all I needed to immediately know that this was gonna be a great explanation. Its like you can read my mind in the beginning wth.
Edit: After watching it all I was genuinely shocked at the similarities of how our minds work. I explain things just like you do and now I realize why people find it hard to understand me sometimes haha. I understood you though. Your explanation was basically 80% abstract thought and 20% communicational conventions (i.e. what we all agree on when we say words). I really wish there was a way to just send abstract thought over to someone else instead of trying to compress it down into words.
Really appreciate your comment thank you 🙏
literally Charlie the moist critical, but a programming youtuber
Wooohooo! yeaaaah baby!
real genius indeed
cheers :Da
Watched a couple of your videos and Subscribed just now!
Awesome thank you
Bruh. I'm too dump() for this
Very informative video, cheers for creating them
Thank you for watching:)
Damn, when excatly are you explaining what is the reflection? I watched the whole video carefully and I feel like I missed something because it ended and I still don't know what the reflection is exactly :/
Code is data, you’ve written a program and there is data you can extract from you program. Reflection is reading data about your program at runtime.
thanks man for great video
Cheers
Amazing videos, thank you
Thank you for watching
Hi, I'm getting this error "CS1061 'string' does not contain a definition for 'ConvertTo'"
Bro thanks for tour :) that was great, ı wonder about it was a show how we can do with reflection or it was a real scenario, I came here because I am looking something in reflection I would like put many of strings into one string with reflection, like property names are name1,name2, name3.. I dont know how much it is, when I read this from excel, I have to put all that to one list names
Sorry I don’t quite understand
Haha me too :) I dont know what I was trying to say, but I wonder about the auth claim with reflection is really needed or it is a show to see what we will do with using reflection
It’s a demonstration
@@RawCoding Okey, thanks for it. Reflection is really interesting :)
Another great video, thanks for this! One thing is that I guess you could set "inherit" parameter to true of "GetCustomAttribute()" in order to get that "Authorize" attribute from the controller itself, instead of adding " || x.DeclaringType.GetCustomAttribute(authAttr) != null)".
Thank you
Awsome video, thanks
Good stuff.
14:45 I downloaded your code and it compiles. When I try the Startup(null) like you show it cannot find Startup. I added the WebApp.dll from Bin folder but it doesn't see any namespaces there.
If you don’t have a payed version of LinqPad you need to add the namespace manually, press f4 and it’ll be there
@@RawCoding Thanks I had tried that but my problem was I was not using LINQPad as your project is DotNet Core. Just got it working and continuing with video, Kindly!
Ah alright
@@RawCoding meant to say I wasn't running LINQPad 6. I bought the ultimate edition
Good one brother
Awesome Anton.
Thank you.
#professorrawcoding
#raw_coding
Cheers :) Remember that thing I was talking about automatically generating claims? This is basically it
@@RawCoding Yes I remember.
Trust me, in time you/raw_coding is going to be the goto for all developers using the development stack that you have knowledge of.
You will soon have no time for yourself : )
@@RawCoding "Remember that thing I was talking about automatically generating claims?" Yes I remember very well.
@@ricardothomas3779 I second that
Please make a video on Reflection.Emit if possible
I never used it so I can't sorry :)
This method .dump does not appear to me. What am I missing?
Its LinqPad only
@@RawCoding thanks!
seems like getting project for a Coursework that involves reflection wasn't the best idea
Great work and thank u so much for ur work! A video about marshaling would be nice.
Haven’t done it before so I need to try it first :)
Can this be achieved with razor pages
Why so many "\" in that json format?
that's what json is gotta escape the " to not close of the string
IMO, i mean when Reflection does click for you, this video will make more sense.
what would you say is missing from this video?
I wish I could have a tutor like you. Thank you for the work ur putting into.
Thank you for watching
They way you typed it doesn't work for me. I had to use Single Quotes in the Split Parameter.
"Hello World".Split(' ').Dump();
Mmmmm
Jeepers, is it like kind of hacker or reverse engineer?
Nope, it’s code as data
They call him Jesus of Programming xD
Hehe
Great explanation, but maybe write a script beforehand; this video could have been half of what it was.
Crack
Nice haircut
Eyyy thanks
Where are you from? Your English is very good, but it sounds as a second language. Like something one would be taught at school.
I am from Latvia
You go way too fast