This tutorial looks at how you can use the Diff window to compare the difference between two files or two versions of the same file. If one of the versions of the file is checked out in your workspace, you can modify the file as you run the comparison. You can also use this window to conduct a code review of some changes to a file.
- [Voiceover] Context is kind while writing code. The more information you can have at your fingertips while writing code the easier it is to keep your mind focused on solving the current puzzles in your application. That's why Microsoft introduced the CodeLens feature in Visual Studio. It's a tiny inline info pane that gives you critical information about who's referencing the methas in a class. It can also tap into the source control system and show stats about who is committing the code. CodeLens is available in the Visual Studio Professional and Enterprise editions.
If you have either of those editions you'll want to use CodeLens. It provides valuable information. It's enabled by default. I usually turn it off while recording courses. Here's how to enable it. In tools options I'll search for Lens. Then I'll check this top check box. On your machine, you probably see all of your check boxes checked. I've disabled them or unchecked them so I can add the features one by one. So currently all I have is the show references feature. Visual Studio inserts some extra space my code lines. You can see it between line nine and line 10 and this little text here. That's the CodeLens.
This tells me there are seven places inside my code that reference this property and I can click on this and read more information about that. Return back to the CodeLens and I'll start turning on some features for TFVC. That stands for Team Foundation Version Control. So the first thing I'll do is turn on show Timeline. When I return back to my code I see there's a new bit of information here. So if I look at the NameProperty or the StopNumber property I can see that Walt Ristcher edited this two days ago. And when I click on it it shows a timeline.
Line 10 shows Terry Dactill edited this 23 hours ago and checked it in. And when I click on this there are two authors and I can see that Terry checked it in more recently than I did. If I wanna dock this window I can click on this symbol here. Next I'll turn on show the show authors and changes and while I'm here I'll also choose show incoming changes. Now I can see that two authors have worked on this. One author on this part, two authors on the class itself. And I can drill in at anytime by clicking on this in the CodeLens.
I'll drill down to this one. This one has two authors and it says here there is one older version of the property including the local version and a newer version. So that's telling me that I have a copy of an older version and that there's a newer version available. I can click on this and see more information. This is the local version that's the one that I have and that's on changeset 45. Terry has checked in a newer version at Id 50 And I can get the latest version. I can also show all file changes. That takes me over to the normal History window.
Let's see if that works in TourStops, move over here. It sometimes takes a few seconds for it to show up because it's hitting the server and pulling information in so yeah it's working too here so I can see that on my TourSource class Terry made some changes 23 hours ago and that there are several changes here. Once again I will reiterate if you have the Enterprise edition or the Professional edition I encourage you to use CodeLens. It's really helpful.
- Source control principles
- Signing up for Team Services
- Creating team projects
- Adding projects to source control
- Checking in and checking out changes from the repository
- Adding users to a team project
- Tracking work items
- Adding projects to Git
- Using history to understand team commits
- Using tags to label versions
Skill Level Beginner
Q: This course was updated on 08/23/2017. What changed?
A: A new video was added that provides notes for Visual Studio 2017 developers.