GitHub Copilot For .NET Developers With Visual Studio & C#

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone welcome back to AK Academy with this new video uh while I'm going to review basically uh the new utility that you have been uh of course hearing about recently which is the GitHub uh co-pilot uh get up copilot like it made some noise recently um because of it is basically if you check their official website it says in a summary that your AI peer programmer which is basically utility that's going to help you write code by like completing some code Snippets for you or suggesting some full code Snippets for you classes methods and stuff like that so basically the majority of the stuff that you're going to find online when you are checking if this utility is good for you now is mostly for Python and JavaScript um even on their website like you can notice in here like they are talking about go Ruby and rails um JavaScript Java but no one mentioned.net so basically this is the video where I'm going to show you my uh my experience with this uh getup copilot for the past two or three months uh using it like full time I I'm using it in my work on my YouTube tutorials one of my open source projects or even when I'm like doing some algorithms and data structures and this kind of thing so basically uh yeah I'll be sharing with you the real experiment that I have uh found after this experience and whether you should go for it or no so I will be covering some points uh like five or six points throughout this video where I find this uh the GitHub copilot very efficient for me where it's actually helping what is the percentage of its of its help while I'm writing code using using mostly C sharp and like on a different environment whether it's Blazer it's a speedy Azure functions whatever it is it is very good in in multiple cases but first let's understand like very quickly how basically GitHub copilot works so what it does is it is backed by the cloud so it learns from the public repositories available out there on GitHub and so it has like a wide range of experience from different repos different projects different type of projects and uh 100 maybe thousands or millions of programmers uh this is the it's it's measles for knowledge in addition for that it learns from you it turns it from your own code from your own repos from your own Solutions the projects and it tries to adapt for your own coding Styles so this is why if if if two developers actually created the same file with the same name with the same projects sometimes GitHub copilot would not suggest the same uh helpers for for you or for the other developers because it tries to adapt for your own uh syntax so basically it learns locally for from you and it learns from the cloud and the more like over time it's just going to get better and better because it's not kind of expert system where it's packed by F and else's and stuff like that no it is fully using Ai and machine learning algorithms that's making this work happen so basically the more the people use it more repos out there it's going to be better and better and of course GitHub respects all your privacy if you don't want to share your code with it and this is like another topic but let's move right now to some points that I want to share with you uh using copilot in my visual studio so here I have opened the three different solutions those are demos this is not like uh like this is the plan wrap course that I have on my YouTube channel this is the open source library that I have and this is the other course that you are going through which is the AK expenses tracker like a serverless application that runs using Azure functions so we will see how good it is in those different stuff and what kinds of things that it helps me with I will start first by the most thing that I like about GitHub copilot is basically removing the repeated and boring code that you face while you are writing new projects or existing ones when you're modifying whatever there is always some kind of code that is very boring to to to write and it's very repeated one of this code is for example if I go to planner app course a planner app is a webassembly project so which means it's a full front-end project right so to communicate between the front and the server side or the API you need you need to use HTTP clients to make those calls basically happens and to to make this happen basically what we need to do is we need to use HTTP client to make get delete requests and the the bigger little project is the more those requests exist you can write some extension methods and you can write some helpers but still like there is some this code is like feeling very boring because it's not 100 straight to the point of what you are trying to do like that so I will open right now the HTTP plan service so let's see what it contains if I check the methods in here like it has great async delete async edit get my ID get plans async and some like helper functions so in here as you can see those schools are actually like here I'm making a post request to create a new plan or making a post request to edit get and so on and so forth so basically I may like using some helpers as I've said creating extension methods to reduce like this code but still like it is sometimes it is you know you have you have to write it and actually GitHub go pilot is very good at managing like once you write a little bit of them he is very good at continuing though so for example let's talk about that there is no delete in here so if I removed it and right now I want to write the delete function so what I do is I will start by typing public async task delete async and then I will pass an ID in here like that and here we go so GitHub copilot makes this suggestion that actually continues everything if I hit tab okay it's added another curly brackets for me but that's okay so it wrote the full lines it manages the the URL based on because he knows like how the URL looks like this plant is because okay I don't know how exactly it's working behind the scenes because I'm not very good at AI but like basically from a high perspective if you notice that all of those within the plans service to this is the URL and because it's delete so it has to be like delete async and not post or get this is ID and it's not going to check like here when you are getting by ID we check if it's successful so fetch the data from the body of the response but because it's delete so there is nothing to retrieve it just delete so just to check if it didn't fail because if it does just throw an exception so it didn't add the first part of the code which is check if it succeeded and retrieve something there is nothing to retrieve which is which is very good so it's written that for me and it saves me those four lines either to copy them or stuff like that so even when you have more and more it's always helping even like if this if your style having or functionalities has more than this it will do that based on your previous code and it will try to suggest all the changes that you need based on uh like based on the context of the code that you are writing in so if you type delete async in some other files the it's not going to be the exact same thing but because he knows how those file looks like how this project looks like this is why I suggested this thing so that's that's something very very useful and it does this very well and sometimes when you're writing repeated code for me sometimes it saves you like more than 50 of the time which is very good sometimes more sometimes 70 sometimes uh 30 but overall it is very good at doing this let's see another example of writing bullying code so for example when you start a new project and you are using Entity framework for example so you have a set of models you need to create and you need to fill out the properties you need to create the enums and for me this is like extremely boring thing uh actually GitHub compiler is very good at doing this so if I go to shareit for example I'm not right now in a but [Music] web API but still like the idea would be somehow the same so I will create a new shared I'll call it book.cs as an example so I have a class called book I'll remove the class and I will type it myself public class book and create a little here we go so GitHub copilot suggested everything that's not everything like 100 of the properties but somehow like the majorities of the stuff that you need in the book is already there you know that and he gives you the suggestions if you need more that's okay hit enter and it will try to think of let's be more so I will add like date time create the date okay come on here we go so the more you write the more it it adapts to basically what you are trying to do so we need an ID for example we need we need the total Pages there is user ID so that this continuation is not hard this is already existing in Visual Studio but you can have like this and like so it helps you with this sometimes it is more than this so the reason why I didn't add all of this for us is because I am in a DDOS file where actually we don't have too much IDs and too much like modification data and stuff like that those are details not full models but if you are phone models sometimes adding all of the code for you which is very good but still it saves you uh instead of writing 10 lines he wrote five for you so you still have to write five this is in this case which is 50 that's a grade um and that's of course more like if I have a class shopping cart and in here we go so it suggested that we have a quantity we have the creation date of this shopping cart update date user id idea of the cards and the book quantity that's good of course sometimes it is not always 100 so you need to make that the change that you need to do but still it saves you some some time like editing a list code is not same for writing it from from scratch it's always with enorms like it if I type public enum book status as you have seen available not available this is in the stock for example another example let's take like public enum severity low medium high so it is doing very good with this kind of things it really saves you a lot of time and I like this utility when it comes to this kind of thing so if you are looking for this if you have a lot of this kind of boilerplate code or you have a lot of like properties generations and this one is absolutely amazing it's not only about this like it also properties it does more but this is what it comes to my mind right now this is the first point that I wanna cover right now let's move to the next one which is basically [Music] uh while you are writing some kind of you are writing business logic and this business logic is actually requiring some kind of algorithms or like problem solving actually GitHub copilot is perfect at doing this so let's take an example I have in here in the planner app also I have I will give a like simple example then I will show you a real world example that I have done if we go to components plans and we have here plans cards list so in here we have a like list of or a page of Blends so a page and inside the page we will have if I check what's inside that page if it's called result Dot so you can see that we have records records which are the items so which is innumerable so I need to shuffle those items uh randomly like I just need to I don't need them to be seen in the same order that's that that they come from from um from the server I need to shuffle them randomly so what you can do is maybe check stack Overflow if you are good at writing link you know what you're going to do but still GitHub copilot can can save you both so all I have to do is I'll take an example private void Shuffle plans and then I'll do it a little bit and look at that it suggested that for me what happened is it made a mistake it says result.items well actually the name of the properties is records but it is my bad I think because I called them here items count I'm calling it here records and actually I don't think the Name Records is very common so items makes more sense so he's right I'm wrong so this is another benefit you have to be here with your names to actually tear with your names and your your conventions to be to get the best out of this but still it manages to shuffle them and let's see the solution that it suggested so basically he says I will order your records by random new good every time that's perfect that actually gives you the the uh the result on here for example void or let me try to use comments instead of a method um I will call it like order their results by title the title of the plan so what I'm going to do in here it does that already so it just existed and right now he knows that okay it is called records it's not items so he improved what what he was doing and it ordered them by title so that that's very good right and there is actually sometimes more complicated stuff and it just helps you especially when this kind of things when you need to go to stack Overflow to check for multiple Solutions githubality is perfect at doing that which is which means like you're going to go to stuck overflow less and that's that's perfect not because this means or like stack overflow will be out of course no but GitHub Cobalt is already trained of what is there and sometimes either you are like Junior developer very senior developer you don't remember anything there is some stuff that you write from time to time and you don't always remember it GitHub copilot always helps just describe it correctly in the code or name your method perfectly and it will be helping you one time I was in my work uh GitHub gopal that helped me like uh perfectly which was we have a task where you have a list of items just like those in here that you can see right now in Windows in the taskbar so the task was included is that the user can sort them just like this so for example here this item he wanted this item to be in here so if you just push it like this using drag and drop and then he can bring it back and this order affects some other business logic in there in in the code so I need to write some kind of function after I created the components designed the stuff I need to write the logic of the swap because the swap is it is not too hard but it's also not very easy or straightforward to process because there is some as I've said business considerations in there so what I had to do is to write a code that there is some arrays like whenever you move this so make sure to push everything in front one step back and vice versa if you're going in the other direction and make sure that you keep the sequence correctly and what I have done is the function was like around 20 lines of code so I have to have like void Swap and here I pass first item and I passed like second item and then at that like this and I'm thinking about what I should do and boom like GitHub compiler written all the code for me it even put the considerations based on the read that I have and the the context of the component that they have and he does everything perfectly so I just had one tab fixed some names and I was very good so it saved me like 15 to 20 minutes in one in one single tab click so that was amazing and actually this is another way another reason why I very recommend this utility for you to get started with what you're going to talk about the cases at the end why you shouldn't get it in in some scenarios so this is the point right now let's move to another one which is comments another big advantage of using GitHub copilot is comments comments is the crucial part of your code always like you need to describe how this function work what if the upcoming line is doing or what the upcoming section is doing what this method is is doing or this class is for this property or whatever so it is for yourself to keep your code clean and readable it is for yourself to be able to come to the code later and in some cases it is mandatory because when someone else written the code and he gives you like a function of 20 to 30 lines of code but it's not commented so it's your own work to basically understand the code and to know what what this code is actually happening to to know how to use it or even to modify it githubality is perfect at writing comments so let's take an example I would go to the register form in here so we have the register form and it has like if I go to the code behind so this is the code behind register basically has like register user async method that does the things okay for this case this function is is easy to read so you can you can read it quickly but this is a good example for us if I want to write comments for this what I will be doing is I will add something like that and then I would wait a little bit okay it suggested something that's somehow readable but I know that radio series racing is going to register a new user but you can push copilot to to to to tell you more about what is inside by typing like for example uh Buddha Space with given credential okay let's put another space and navigate to the login page okay that's that's very good right so despite that this one is a symbol function but it tells you what it does like using Giver credentials maybe let's try to using credentials let's try to push it more by typing like pi okay it doesn't tell us anything so I'll remove okay by calling the authentication Service okay and redirect to the login page that's very good so interesting this function for me so I written three words instead of this so even if you understand what this one is doing I just want to write comment for others to know GitHub copilot will save you like instead of writing 20 words you are going to write three or four so that's 70 of your time that's that's good if you are going to say okay this line this line actually counts because when you are working over the full day um like couple seconds from here this line I saved like one minute from this method I save two minutes this method I save uh 10 seconds you'll end up like with additional two hours in your day writing code this is in like an average maybe maybe you can have more uh also for Lines by lines uh GitHub copilot knows what what this one is doing calling authentication Service and in here it can tell you uh describe like it's each one of those even as I've said for complicated the functionality sometimes it is doing very good at writing comments uh for those and so that's another reason why some people sometimes ignore comments but right now you can do that so for example if I came in here added this oh no it's not get the plans from the server it's basically create a new plan by calling the API okay so as you have seen it's not always doing one one hundred percent but it's based on the context but still on the comments it is doing very good I'm satisfied with this experience now let's move to another point which is the unit testing you know that GitHub compiler is also very good at unit testing unit testing is somehow it is interesting but time consuming at the same time and the GitHub co-pilot is very good at actually helping you writing those tests so I will move to my open source Library which is um AK localization multi-languages so in here this um unit testing class that contains some tests for the I language container service which is basically like a service that has some c-sharp sorry some logic to retrieve keys of a specific language that you can use in your apps and the functionality called the change language that allows you to to change the language so I want to make sure that the change language function is working perfectly and it's actually changing the function so to write a unit test for that I'll type testing here and then I will type public void change language should change the language correctly so this is just a sample name so after I open oh look at this so after I describe what I want to do I just hit Tab and my unit test actually has been written so what it does is it creates a new instance of the keys provider a new instance of the service okay he knows that from other classes he set the language to is Spanish by default um of course it learns from other stuff and he tried to retrieve a key which is the hello in Spanish and it should be all and if it's like this so that's good then try to change the language and make it English and retrieve the same key and if the value is hello so you are good so basically it's written the whole unit test it understood what you should be doing and he did it perfectly the only thing that he didn't do correctly the name of the function what's wrong because because it's called set language so it's again it's my problem it's actually changed and not set so actually rename the function but so hola instead of writing all these codes I just have to do this and if I've written the name correctly that makes more sense I didn't have to do that so uh actually this is just a simple example it helps you more and more of course don't depend on it to write the fully test for you every single time like the full function just change something but like instead of writing like 100 lines of code it's good to write like 90s and if 90 only and it's if you can write only 70 50 that that's better so even if you save a line that's that's that's good so those are actually somehow the main point that I want to show you there is some little things here and there that actually very useful in case of using GitHub copilot like for example especially when it comes to this stack Overflow there is some code that's not depending on your experience but it is just there because you need how to use it like upload a file to Azure blob storage so how you know if you haven't used this the SDK before how you're going to upload the file even if you're an experienced developer you need to go check a stack Overflow check the documentation and stuff like that GitHub copilot can do that for you if you are in the right context and you call the function like save maybe you call the class Azure blob storage service and then there is a save async it will basically go ahead and write that code for you so all you have to do is just to bring their packages and install them let me show you an example here in the AK expenses Tracker Where I uh when I have seen this in action actually is in here I have istor service that's called it has save file async and delete violating and I have implemented an Azure blob storage service for it and most of this code has been written by GitHub copilot actually uh also if I want to write like a new functionality uh GitHub Cobalt is very good one more example which is very useful that doesn't make you go to stack over the flow with get content type like in here when you are uploading a file you need to set the header in for for that file over the web so he knows that the content of this request is like application Json image PNG image GPA jpeg or uif or whatever so uh usually if you are not familiar with those you need to check the dictionary online to know like check some I don't know Wikipedia or Firefox website w3schools just to know the content type for a corresponding extension but get a ballot know that so it saves you the time to go and make that research for this fixed thing so if I type in here like dot mp3 for example is it going to yeah here we go so it knows what to suggest and if I type dot PDF is going to do that for you so this is little swing but it is very important because you alone are not going to know this string especially if you are using a new extension like I always upload the PNG file so I know that the content type of those in the web header is image PNG same for PDF but I don't know the rest so I actually GitHub copilot written all of this for me and it makes my life very easy because I don't have to go and make the research online and bring the table is doing that perfectly uh one more thing I need to replace a file so just upload the file on top of the other one so I'm right now already within an Azure storage service so he knows the context certain type is public async task replace file async and I will upload that stream file string file Pass the full file the full path of the file if I hit enter let's see what GitHub Cobalt is going to do it is everything that's perfect right um why we get an o because you always add an extra curly brackets but he has written the full method I don't have to change anything he knows that they have to fit the container you know that this is the file path and the file path is not important while using the blob because if you have the container you just need the file name he extracted the file name he used like he get the reference for blob and he tried just to upload on the same blob so it will be replaced and he knows this code from from here is very genius he saved me tons of time in this method so this is basically the most important thing I want to show for you in this in this demo and I hope like you enjoyed it uh the last thing and the most important thing is when I shouldn't GitHub get GitHub pilot okay first of all if you are new to programming or if you are like learning C sharp or maybe other languages that supported by GitHub copilot never get it because it will write a lot of things for you even if you look at the code and you understood it it is not the same of writing it by yourself so GitHub Cobalt will will save time only if you are in a level where you are working on the projects and you are very good at writing code you are learning on the way so it's it's not you don't understand anything and you are trying to understand or step by step if you are in this case never get it like Let Me Show an example save file lacing if you are saving using PHP JavaScript Robbie c-sharp whatever it is the concept is the same and whatever the storage you are using Azure blob storage or something on AWS or local in your folder that steps at the same you need to get the file you need to check the name you need to make sure that the extension is valid you need to make sure that the size is valid with your server then you need to create a new unique name then you need to save the file on on your storage provider so the steps are the same GitHub Cobalt is going to write them for you so if you look at them it's easy to understand what this code is doing because it's commented but if you are new to this field it's not easy to write it you need to know those steps and you need to let your brain think about what's next why I need to check the the the the size so why need to check the extension what should I do you need you need you need to think deeply and you need to make your brain work more and more GitHub compiler will prevent you from doing that so it will be like an enemy of you for to to learn and Advance your your thinking in the domain uh this is the case the third case if you are doing like [Music] uh competitive programming and using like a lot of algorithms and these structures uh GitHub globality is very good at doing those because there is millions of lines of codes existing online above that and GitHub copilot actually know them very well so if you type in here like I'm not sure if I'm the context of store of storage you will understand but let's see pool uh binary search and here I'll give it an array wait a little bit here we go he has written all of the code for you so if you are doing competitive programming and I don't think GitHub copilot is a good option for you because it should be doing your work and not 100 but most of the problem that you're going to solve is existing online on on GitHub and on stuff like that so he will already learned that so let's grab the problem in here and he will resolve it for you so if you are learning and you are looking for the solution it will help you but if you are pushing your brain to find the solution get a copilot will going to prevent you from doing that because the moment you write the name of the method it will write it for you and yeah I don't think it's it's a good idea for the third stage cell uh yeah this is everything I think um I explained uh the major point that I found useful and the point that I don't find useful and you can actually my summary for that that if you are an experienced programmer who is writing code to build the projects and um like you're not just writing code to learn I mean so go ahead and GitHub copilot it it fully deserves it saves you tons of time and hours during your day month weekly a month and that it's actually totally worth it and it's not expensive when it comes to this case because I think it's around six or ten dollars and a month so for I know for some reasons it depends on the region and on the situation the salary the company are working for but it's still uh like 20 hours a month or or 50 hours a month of saving code and removing those bullying stuff and making your code enjoyable as you know that you're writing a method and suddenly your method gets completed like very quickly by one head of a tab is actually worth ten dollars a month so this is everything you want to talk about I hope you enjoyed it and you can find the link for the GitHub co-pilot in the in the description box below a very quick note to get started is something very simple I'm just talking about individual studio in here just go to extensions manage extensions and search here for Copilot and you're just good to go install it just install it after you install just hit on the free trial gives you also I think 30 or 60 days free trial I think 30 days free trial and uh yeah you can you can test it for for free at the beginning and then if you would like you can continue the service or no so this is everything for this video I hope you enjoyed it and um yeah don't forget to hit the like subscribe and share button to support for more content and thank you so much
Info
Channel: AK Academy
Views: 18,049
Rating: undefined out of 5
Keywords: Software Development, Visual Studio, Xamarin.Forms, C#, .NET Core, .NET, Microsoft, Programming, AK Academy, Ahmad Mozaffar, Blazor, Blazor WebAssembly, Web Development, Visual Studio Code, ASP.NET Core, Desktop, Window, Windows 10, Mac OSX, Linux, github, copilot, ai, ml, machine learning, ai pair programmer, unit testing, comments, understanding code, intellisense, intellicode, classes, object oriented programming, stackoverflow, programmers helpers, git, repeated code, biolerplate
Id: Hf9HQVPinqQ
Channel Id: undefined
Length: 34min 41sec (2081 seconds)
Published: Fri Oct 14 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.