10 C# Libraries To Save You Time And Energy

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
to kick off 2021 i want to share with you 10 of the libraries that i find helpful in my c-sharp development the best part is that these libraries are mostly if not fully free they'll be at least free for you as a developer but it may cost something in some commercial applications well i think two or three of them do though now you see as a developer i like to focus on the primary purpose of my project if i'm building something that is focused on uh i don't know helping my clients in the retail industry that's my focus and so anything else i could build but the reality is that's not the focus of my my project the focus of my product is that retail application and so i'll bring in libraries to help me do the rest that way i am focusing on building what is unique to my customer and yet i am still giving them a great product all around because of these other libraries we do this all the time as dot net developers because you use things like console writeline console read line that's a external project that you're using in your project because microsoft did it once why we need to repeat ourselves just because we could and that's what a lot of these projects are are things that will help you even though you could do it yourself these have done it better now if you don't know me my name is tim cory and my goal is to make learning c-sharp easier every monday i post a c-sharp code video of some kind and every thursday i answer your questions in the dev question series i answer questions like how i get a job in c sharp or what should i put in my portfolio now if you have questions i love to have you check those out and see what answers you can find if you want to go even more in depth i you can go over to i am timcory.com where i have courses that are foundational all the way through in-depth courses now today's a bit different instead of me showing you how to build something i'm going to point you towards 10 projects that will help make your code better but if you find one of these that maybe you think is a little too difficult to get into or you just want to see me demo it let me know down in the comments below i'm gonna keep track of those comments and the upvotes to those comments and we'll see if we can't arrange something if it's popular enough that you really want to see it okay so let's head on over to my browser now here i've got open the 10 different projects where i'll look at let's start with number one and this is the sharp zip library now this thing is pretty awesome because there is zip file creation and management built right into dot net but this takes a lot farther this creates a zip gzip tar bzip2 and a lot of libraries i've never heard of but it creates all the really cool and useful zip libraries and it can read from those libraries as well so you have to deal with files whether you're backing files up moving files taking files from a ftp site unzipping them whatever it is you can do it all inside c-sharp using this library very easy to use they got the instructions one of the things i've i like of these 10 libraries is they all have pretty good instructions so this is no different this is how you install it all right and then it talks through how to use it you can go to nuget and i'm sorry github and find all the information about it and what the different libraries are and how to use them so really cool stuff there again i'll leave a comment in the description down below i'll leave all these links the only copy links down they're down in the description okay so that's the first one is sharp zip lib number two this is a the first of three that focus on email and each has a different uh flare to a different reason to exist the first one is fluent email and this is the really simple email system now when i say simple i don't mean that simplistic it has a lot of cool things for example it has the ability to connect to send grid or mail gun or mail trap or mail kit or just an smtp server but this basic usage right here it can't get much simpler than that let me zoom in here a little bit so you can really see that it all it is is once you start using your code you just basically say here's the email go send it including doing things like adding um templates in there so you can have a template templatized email and then just pop in here put the values in the right places and away it goes so if you need to send email through c sharp this is the place to start and look to see if this will do it for you now there are times when you need a more in-depth uh email client we need encryption or other things and that's where mail kit comes into play mail kit is is that more in-depth okay for example here's all the different authentication systems proxy support client support and types pop clients imap there's a lot of stuff this thing supports and if you need to go in depth then mail kit is the way to go it's built on top of mime kit so um this is crossplatform.net core everything really cool if you need the more in-depth email now like i said if you need just standard email stuff that would stick with fluid email it's simple it's easy to use it's quick to use and it's really helpful if you need them more in depth though that's where mail kit comes into play okay so that's number two and three number four is the last in the email set setup and this is my favorite little tools i have this installed everywhere i go because it's just it it ha it's it's so helpful what it is is called paper cut smtp they've just renamed it from paper cut to papercut smtp new logo is coming soon um it's right there but what this does let me show you there we go this is a little client that sits on your computer and when you are building your c-sharp application that uses email so whether you're using fluent email or mail kit whatever it is what you do is you point your your email system to localhost which localhost is your computer and then you run papercut and so what it does is acts like an smtp server so that you can test your heart's content your your c sharp application and it won't send any email out that's the thing you can't really test something end to end without sending an email out but that's a problem because the fact that you're dealing with a real email system and re really email addresses you don't want me doing that for testing purposes so you can do it this way and it will act as the smtp server and an email client so as you can see here this welcome the paper cut is actually an email that they sent into papercut you can see the from the to the date subject the message the headers the bodies the raw the whole line yards you can see that in the email so you can see all the emails that your c-sharp application sends you can read them and see if they look right all right so it's a great testing tool i have this installed like i said on every machine that i work on because when i'm going to be sending emails that's working pointed to in fact i never point to anything but that except when it goes through the the ci cd process where it replaces my email credentials with the real ones i never want to send out emails to real people for a test purpose you've probably all done it but um if you've done any kind of email work but it's not something you want to do okay it's not a good look you definitely want to have this in place and always be sending to this for testing purposes so that's paper cut it's really simple to use you just download it install it and then point your your smtp server point it at your computer okay pretty much it number five this is a tool that has changed over time it's called ep plus and what this is they just changed our licensing so now license is polyform non-commercial and you can read about that basically it's still free use in some cases but they said it will require a commercial license to be used in commercial businesses this is a tool for reading and writing excel files and in business excel files are everywhere this is a way to integrate your c-sharp applications with excel whether it is reading from somebody's excel spreadsheet or creating excel spreadsheets kind of like a reporting tool really helpful stuff this i use a lot and they just change over from a fully um a fully free model to this paid for commercial use the reason why is they weren't making any money and yet they were one of the most popular packages out there so that's hard to maintain it's not agreed thing this is a they're getting worn out trying to support something that had hundreds of thousands of users without any income so they changed this commercial must pay license but it's still a great product it really is fairly simple to use um they have good documentation on how to use all of it they have added some new things here i think they have a website now as well um they talk about you know all the things they can do with it and it's uh 299 a license all right for one year or pay as you go is 29 a license that's per month so um but developers you can use it for free um it's just when you put it into a commercial license you have to pay for it now some people get a little uh quirky about that and say well i shouldn't have to pay um if you're building something commercially then you should be paying for that kind of stuff you trying to create something that will do that in excel is going to cost you more than 300 a year guaranteed maybe not in money but in time which is the same thing so pay someone to do it because you if you have a commercial application you're making money spend some of that money in order to make that money so focus on great tools and that will get you a long way an ep plus is a really great tool it's like i said really easy to work with and as a developer you can use it for free you just can't publish your app commercially okay so that is ep plus i encourage you to check that out if you have anything to excel that's a great one all right number six hang fire you may have heard of this one you may not you may not be quite sure why it does but hang fire is all about uh executing jobs let's take for example um i used to be an i.t director and so we had a lot of jobs on our servers that executed automatically for example every night we have the sql server backup okay well that was a scheduled job so we said every night at this time i want you to back up sql server well there's the same kind of jobs you might want to do in c sharp you might even have the c sharp job execute a sql server backup or from the first library that sharp zip lib you could say let's grab all these files and zip them up and archive them back them up somewhere every night you can create a c-sharp application to do that or synchronize files or any number of tools clean up your your database um archive client records create reports the list is endless of things you can do on a somewhat regular basis so there are recurring jobs and that's what that would be is those jobs that happen a lot but there's also other types of jobs as well like fire and forget jobs say hey you know what just start doing this i don't care about the results just make it happen um like a one-off type of job there are there's a pro version of this which can do batches and batch continuations um but delayed jobs so you want a job that you want to have done but not right now so maybe you say you know what before we switch over the new database server i want to make sure you have everything backed up so do the backup but let's wait until end of business to do that that would be a delayed job and then a continuation is you can kind of change jobs okay when when this is done i want to do that next so a lot of really cool stuff not only is this tool great for saying those things up but it also has a dashboard that will allow you to see the status of all your jobs and be able to retry jobs or other things as well so great tool this can be you know it can run on a server somewhere and you can have a whole bunch of custom c sharp code that you've written as jobs execute whenever you want so business has a lot of repetition stuff this tool can help you process that and not have to write your own engine for doing these types of tasks i've written my own engine sometimes it's necessary um but a lot of times you can get by with something like this and not have to spend all that time and investment writing all the code around the retries and making sure that you report what's happened tracking what happens and so on so hang fire is a great product to look into if you have any kind of job that you want to integrate into your system to have a job execute automatically uh schedule and so on all right um real quick thing here i used to work in a company where we had these fire and forget jobs so we create pdf reports but so when a user said i want to report it wouldn't happen automatically because it would overload the system what we do instead is say okay i'll put that in a queue and then as the system has enough cycles it's going to create that report for you in the order that people requested it so it may be that shows up 30 seconds later or maybe five minutes later depending on on how busy the system is but that way we wouldn't overload our server with 20 people at 8 o'clock in the morning requesting the same report we could well first of all we could we could um make those the same report and not have to create 20 times but he has different reports we could say okay we'll start processing in the order received it and then when we're done we're done that way you don't overload the system at one point and have tons of free space another really cool stuff you can do with something like hang fire all right the next one we talked recently on this channel about azure service bus and about using queues and i intentionally use azure service bus because i i found it was the easiest way of communicating that topic without adding another layer of complexity but there is other tools out there for example rabbitmq is another queueing system like azure service bus but it's not in azure obviously it's it's just a third-party assistant installed pretty much anywhere and rabbit mq is another great option well there's a tool called mass transit that what it does is it basically abstracts away the differences between rabbitmq azure service bus and other queuing systems so that you can write your code once and then support any of those systems so it's another layer on top of azure service bus but think of it like dot net standard where it creates this interface that then you can call any different piece down below so really cool system it's free open source and all the rest there is a little bit of a learning curve to it but once you figure out how to use it and the documentation is pretty great um there you go there's all the stuff you can do here it's got code samples it talks about the various pieces uh there's azure service bus and how to integrate that and so on but what this allows you to do is basically abstract away which cue you use and allows you to switch between them much more easily that would allow you for example to start on rabbitmq and realize hey you know what we want to scale this let's move to azure service bus which is larger more scalable we can do that by just switching a little bit of code and now all of a sudden we're on azure service bus we didn't have to change our entire application really cool stuff so mass transit check it out um if you're doing anything with queuing next up poly so poly is it's a really cool little library you've you might have seen it before you might not the really cool thing i think about this library is that it does some nice things with working with systems that might have faults but they're little things that it does it's not this huge massive thing that is so clunky it's really focused on what it does so for example there's different policies they have in place i love this little chart here it talks about the policy the premise also known as and how does the policy mitigate that issue so for example let's talk about the the retry policy so it says many faults are transient and may self-correct after a short delay so let's just say you're trying to connect to an api and it doesn't work so you you go your abc.com api and you get a you know an error whatever it times out well that could be the end of the story but with paula you can say actually i want you to try again that's a retry policy so let's just say i want you to try again in three seconds so what that system would do is it waits three seconds and then try again to see if as they're aka maybe it's just a blip maybe there's some kind of weird network issue but it's gone away and this allows you to configure automatic retries so let's try it again maybe a couple times okay but the next one is circuit breaker well maybe there's you can give a system a break so if you keep doing that retry over and over and over again but maybe it's just not just you maybe you have a lot of different spots in your application that are trying again and they're all trying they're all doing retries that can overload a system pretty quickly so what the circuit breaker says is let's do a timeout for a minute let's not try it at all for a minute let's clear the board here because if we overload this system retrying even if it comes back up it was a little shaky we're gonna crash it right back down to his knees because of all of our retries so the circuit breaker policy is let's pop that circuit breaker let it cool off and then we can come back to it later maybe so really cool stuff timeouts bulkhead isolation caching fallback policy wrap a lot i said little things but at the same time the things you'd have to write in your own code all these different policies well these policies can be written by poly okay and even better it's a a fluent type system so you can add these things together you can you can figure out how they work and define them very clearly and readably so really cool stuff that you can do here and like it's great little system that is up to date they're continuing changes on it i think the latest release was in may of 2020 um and you know they're still working on it today so great tool check out poly check out how to use it as well like i said if you have any questions about any of these tools and if you find that the documentation is not quite clear enough you'd like to see more let me know down in the comments i'll see if i can add it to the schedule for upcoming videos all right the next two i have shown up before my videos so if you have questions on these i've already created a video for you i anticipated um so go look at for those but ceralog is the next one that's number nine this is kind of the new de facto standard for net logging it used to be log for net i loved log for net once i figured it out and i actually um kind of got into teaching because of log for net because the the documentation was thorough but not clear and so i spent a long time making it clear in my own mind and then document it for others really more for myself than others but i feared i wasn't the only one that needed to know how to do this and sure enough i wasn't and so that was log for net and that was dot net framework and log for now it worked great for net framework but now with net core we're kind of taking it up to the next level you see logo for net really was about logging data but it was mainly about logging text data and that's kind of what loggers do right so you have let's just say an error and the error is file not found so you might log your your text file system file not found and maybe you might put in parentheses what the file was you're looking for or something like that but it's usually just one big text block and so in your let's just say you store it in sql database you'd have things like the date and time and you'd have maybe what method had the error maybe you capture a call stack if there's an actual exception and then you have your message that's and then maybe the level of the error so it's an error not a warning or a critical but that's pretty much what you captured in your log system the problem with that is it's very hard to figure out which files are problems because even if you put that in the message you'd have to do some kind of regex on a text field to see to pull out those file names that's not efficient okay so the next level up is what's called structured logging where you have that error message but you also break out those pieces into searchable unique objects okay so for the example down here is um latitude and longitude and elapsed milliseconds and so when it stores that information typically what we'd see is this message probably like this right here um that would be stored normally as just one big text blob but with ceralog and the idea of structured logging we would store this text we also store this value for the latitude and say latitude this value longitude and that value and then elapsed time milliseconds that value so we'd store those as separate values that you can query on so that we could say i want any um any information message where the elapsed time was over 30 milliseconds and sql could find that very simply because the fact that it's stored as 34 not as a string inside of a larger string so really cool stuff with logging there's syncs for just about everything a sync is a place to log to so sql database be a sync a text file be a sync a console via sync and so on lots of different syncs but one of the i think coolest syncs is called seek seq this is the place that this is number 10 and it's it's the system that i think is really just awesome for logging logs are not useful if you don't read them don't log what you're not gonna read so if you say well i'm gonna log you know every time a user does anything cool great are you gonna read that because if not you're just wasting space and in a lot of ways you are taking up processing time in your own brain trying to find the real issues so i'm gonna digress a little bit here and tell a story like i said i used to work for as an i.t director and my network director at the time we decided we did a logging system that would monitor all of our different servers we have we maintained all of our active directory server uh actually two of them an exchange server a couple of sql servers and so on so whenever something goes wrong we want to know about it and so we created installed we bought and installed this logging system that would monitor all these different pieces of information and then what would do is it could send an email to your inbox saying hey there's a problem so whenever anything bad goes wrong we should know about it well my network administrator dialed in you know these are things that be a problem so if there's not enough disk space we need to know about it if the network's a little slow we need to know about it if there's a problem connecting to a server we need to know about it and when he turned it on we were getting hundreds of emails a day and so what he ended up doing was just saying send all these email to a folder that he never looked at and we never saw errors because we were we had so many come in that we didn't know which ones were real errors and which ones were not really a big deal for example uh disk space yeah we should know if we're getting down to let's say 10 of our disk space but when the the hard drive is a terabyte and you've got 100 gigabytes left and it's an accurate directory server where it's it's not changing that much size that often that's not a huge deal so we don't really care but we should turn that alert off but instead of doing that we just ignored that alert well that comes back again and so what happened was we had so many we didn't see any and so we actually had servers that had major problems that we didn't catch because the alerting system was telling us too much information and it felt like good information but unless you're gonna act on it unless you read every error don't have it tell you because it's it's even worse than not knowing because by doing that you hide everything so when it comes to logging only log what you're going to read seek helps you read more and the way it does that is notice here first of all the screenshot is telling you all the information about an error so this is that structured logging so it's saying what the application was the customer id the environment the order id and all this great information that's not information i read about every error but when you have an error that information is great to have to allow you to replicate that issue but what it also does is they have dashboards let's see if we can pull up a dashboard here well when you tell me oh screencast i thought i said screenshots that's unfortunate um but in here let's see so there's a filter and search you can filter out your identity information but then you can analyze things over time that can be really helpful for things like you know what maybe warnings aren't a big deal but they're indication of of some kind of problem that can become an issue well if you track that and see the warnings go number of warnings go up over time that might be something or it might not be but it allows you to start looking into it more depth so you do a lot of analysis on this there's a lot of stuff you can do with your logs besides just have this really big text file that you scroll through so seek is a great tool i did a video on cerro log and seek together and how they can kind of go hand in hand and how you get the seek server up and running quickly to talk to your seralog log files and get all that information so i would encourage you if you're going to do logging and you should then use a tool like ceralog to be effective at logging and then use a tool like seek to give you that perspective on your logs to give you that idea of what's really going on so that you're actually using the data you capture like i said if you're not using it don't log it okay so those are the 10 tools or libraries that that i have used in the past and that i continue to use and turn to whenever i have a specific need now don't force these if you don't need it don't use it okay but at the same time when you say you know what when you send emails out don't just try to use the built-in c-sharp email system use start with fluent email and use that to send out emails because it makes your life easier and it allows you to be more secure in how you do things if you need to have even more security you can take another step up to mail kit if you need to zip up files or unzip files that sharp zip lib is there for you to use okay you'd have to reinvent the wheel here and that's really this comes down to is people have built these applications be and spend a lot of time and effort to get them right and to improve and to fix the bugs and all the rest why are you going to redo that use their tool especially open source tools where you can even capture the source code if you really felt like man if they ever go away then i don't want to be stuck with them i understand that but that's where you can use their source code as well so that if they ever did you can still fall back to that so i encourage you at least think through these things through and if nothing else maybe learn from these open source repositories as well read through their code see how they do things see what they had to go through in order to conquer these different issues because then you can look at your project and say maybe it's not my primary focus so i shouldn't have i shouldn't be spending all that time writing that code may should allow you to write that code for me all right so that's it for the 10 thanks for watching if you have questions leave them down in the comments below if you want to see one of these things in more depth leave that down the comments below upvote ones that you see that that you also want to see on a video in the future all right thanks for watching as always i am tim cory [Music] [Applause] [Music] you
Info
Channel: IAmTimCorey
Views: 114,538
Rating: 4.9566493 out of 5
Keywords: c#, tim corey, tim corey c#, top 10 c#, c# libraries, masstransit, serilog, seq, papercut, epplus, fluentemail, sharpziplib, hangfire, polly, mailkit, mimekit, iamtimcorey, c# 20201
Id: uS0hRJqamfU
Channel Id: undefined
Length: 33min 58sec (2038 seconds)
Published: Mon Jan 04 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.