Git for .NET Developers – DevBoston User Group

Slides: Git for .NET Developers

Links

  • Git Project Home: Info and reference materials
  • GitHub: Popular hosting for Git projects with free public repos or private repos with paid accounts. Get the GitHub for Windows client from here or use the GitHub plugin in Visual Studio 2015 RC.
  • Visual Studio Online: Online TFS with Git as a source control option. Free accounts with unlimited private repos all integrated with the rest of the TFS tool suite.
  • Brian Harry wrote a blog post about TFVC vs Git feature support in TFS that might be helpful when deciding which source control option to choose for a TFS project.
  • BitBucket: Alternative to GitHub. You can also get the SourceTree tool that we looked at from here.

(more…)

Read More

Git for .NET developers – Boston Code Camp 23

Thanks to all the organizers and sponsors and to everyone for attending! Special thanks to all the volunteer Changesets/Commits for helping out with the experimental demo!

If you want to play around go to the demo project on GitHub. Feel free to clone, fork, submit pull requests, or let me know if you want to be added as contributor to try out anything without fear of breaking a real project.

Slides: Git for .NET Developers

Git Project Home: Info and reference materials
GitHub: Popular hosting for Git projects and nice client tools. Free public repos or private repos with paid accounts.
Visual Studio Online: Online TFS with Git as a source control option. Free accounts with unlimited private repos.

For anyone interested in using Git as local personal source control on a project using TFVC as main source control you can see the structure in this example Repo.
The changes to make are:

  1. Rename the .git folder, for example: _git
  2. Create a new text file named .git in the repo folder.
  3. In the new .git file add a line to specify the new folder name, i.e.: gitdir: _git

Now Visual Studio should ignore Git and allow you to use TFS instead but other external Git tools should work as normal in the same folder.

Read More

Roslyn and the future of .NET languages – Language Features

Boston Code Camp 22 materials: Slides | Language Features Demo Code | Post on Extensions

The new Visual Studio 2015 Roslyn language features include a grab bag of nice changes to help make code more compact and readable. This isn’t an exhaustive list but some of my favorites.

Getter only and initialized auto-properties

public string Name { get; } = "John";

This is a much simplified way to create readonly properties, which previously required a full property with a backing field declared as readonly. This is not the same as an auto-prop with a private setter, which is still a mutable value. The value can be set from a constructor or in line since auto-properties can also now be initialized directly.

Null conditional operator ?.

NameSize = Name?.Length.ToString() ?? "0";

This is going to be great for cutting down on surprise NullReferenceExceptions and is so much more compact than a string of if statement checks.

Interpolated Strings

Console.WriteLine($"User name is {Name}");

Finally, the functionality of String.Format has some readable syntax! In the current VS Preview the syntax uses "\{Expression}" but this will change to use the $ syntax before release.

Expression bodied members (C# only)

public int CountMultiple(int multiplier) => Count * multiplier;

This is mostly just cutting down on space required for these declarations.

await in catch and finally blocks (C# only)

try
{
    await operation.DoWork();
}
catch
{
    await operation.Rollback();
}
finally
{
    await operation.Close();
}

One of those seemingly simple things that could stop you in your tracks if you were in a situation that needed it in C# 5 and needed a lot of extra code to work around.

Read-write properties to implement Read-only interface properties (new in VB)

Public Interface IHaveData
    ReadOnly Property Name As String
End Interface

Public Class ClassDemo
    Implements IHaveData
    Public Property Name
        Get
            Return ""
        End Get
        Set(value)

        End Set
    End Property
End Class

Another one that’s so simple but could really get in the way when it wasn’t available.

 

Download the Visual Studio 2015 Preview: http://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs

Check out the full list of new language features and latest updates (and the source code!) on CodePlex: http://roslyn.codeplex.com/wikipage?title=Language%20feature%20status&referringTitle=Home

Read More

Roslyn and the future of .NET languages – Extensions

Boston Code Camp 22 materials: Slides | Extension Demo Code | Post on Language Features

With the new code editors in Visual Studio 2015 now written around the Roslyn compiler a whole new level of extensibility is available both for built in features and user created extensions. If you’ve worked with Visual Studio extensibility before a Roslyn extension can a big improvement both in ease of coding and end user experience.

New Refactorings

Refactoring support was added in Visual Studio 2005 and since then a grand total of 0 new ones have been added. Now two new ones have been added to allow introducing new variables and for inlining existing ones. The experience is much improved for all the existing refactorings too.

New Refactoring Experience in 2015

Diagnostics and Code Fixes

Normal compiler errors show up in the editor as you type but can also be augmented with additional diagnostic checks performed by other Roslyn extensions. One key example is a large portion of the existing FxCop Code Analysis rules which were previously run as an additional build step but now happen on the fly as you type, making it much easier to apply these rules right away and keep your code cleaner from the start.

Unlike with normal compiler warnings or errors that you would normally get with FxCop, many of the new diagnostics include an additional component to actually correct the problem for you when possible, even showing a preview of the changes right in line (just like Refactorings).

Write your own!

Visual Studio has been extensible for a long time but there have been major limitations on how deep an extension could get into the code without writing your own compiler. In 2015, a Roslyn extension can take advantage of deep knowledge of the code in real time through the compiler as a service. Project templates are available that make it easy to set up either a Refactoring or a Diagnostic with (or without) a Code Fix. Deployment can be done either through a VSIX that can go up on Visual Studio Gallery, or now as part of a NuGet package that can be deployed on a project by project basis. The possibilities are endless and I expect a huge flood of Roslyn extensions are going to be available on top of what’s already been added into the product.

 

Download Visual Studio 2015 Preview and the SDK: http://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs

Roslyn templates Visual Studio extension: https://visualstudiogallery.msdn.microsoft.com/849f3ab1-05cf-4682-b4af-ef995e2aa1a5

Bill Wagner announcing a new central location for community Roslyn extensions: http://thebillwagner.com/blog/announcing-dotnetanalyzers-diagnostics-and-code-fix-open-source-projects

Read More