diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..940794e --- /dev/null +++ b/.gitignore @@ -0,0 +1,288 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Typescript v1 declaration files +typings/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2107107 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/Productivity-15.8.sln b/Productivity-15.8.sln new file mode 100644 index 0000000..1bc1e67 --- /dev/null +++ b/Productivity-15.8.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2026 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Productivity-15.8", "Productivity-15.8\Productivity-15.8.csproj", "{70A997D4-0D45-4833-A966-FFA8EFBAE1FD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {70A997D4-0D45-4833-A966-FFA8EFBAE1FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70A997D4-0D45-4833-A966-FFA8EFBAE1FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70A997D4-0D45-4833-A966-FFA8EFBAE1FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70A997D4-0D45-4833-A966-FFA8EFBAE1FD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7AD406F0-7164-4B61-A1CF-E505DE651E64} + EndGlobalSection +EndGlobal diff --git a/Productivity-15.8/Productivity-15.8.csproj b/Productivity-15.8/Productivity-15.8.csproj new file mode 100644 index 0000000..2eebc0d --- /dev/null +++ b/Productivity-15.8/Productivity-15.8.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp2.1 + Productivity_15._8 + + + diff --git a/Productivity-15.8/Program.cs b/Productivity-15.8/Program.cs new file mode 100644 index 0000000..28b8253 --- /dev/null +++ b/Productivity-15.8/Program.cs @@ -0,0 +1,14 @@ +using System; + +namespace Productivity15._8 +{ + class Program + { + static void Main(string[] args) + { + // The tips and tricks examples are in the ShowMeUpdates class + // Use (Ctrl+ click) to click on ShowMeUpdates to navigate there! + ShowMeUpdates show = new ShowMeUpdates(); + } + } +} \ No newline at end of file diff --git a/Productivity-15.8/ShowMeUpdates.cs b/Productivity-15.8/ShowMeUpdates.cs new file mode 100644 index 0000000..7fa94ac --- /dev/null +++ b/Productivity-15.8/ShowMeUpdates.cs @@ -0,0 +1,161 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Productivity15._8 +{ + class ShowMeUpdates + { + + // Code Cleanup + // Press (Ctrl k, d) to fix the spacing below. + public void FixSpacing ( ) + { + } + + // Code Cleanup + // If you'd like Code cleanup to include var and explicit type rules + // check the option to apply implicit/explicit type preferences + // in Tool > Options > Text Editor > C# > Code Style > Formatting > General. + // Now press (Ctrl + k, d) to "fix" the types below. + public void FixMyType() + { + var myint = 0; + var mystring = "Hello, world!"; + var myfloat = 0.2; + var mybool = true; + Console.WriteLine(myint.ToString(), mystring, myfloat, mybool); + } + + // Install the Intellicode extension https://marketplace.visualstudio.com/items?itemName=VisualStudioExptTeam.VSIntelliCode + // Be sure to save your code before generating you editorconfig using Intellicode + // Right-click in your solution and select to Add > Item + // Add the editorconfig generated by Intellicode + public void IntellicodeGenerateEditofconfig() + { + // In your .editorconfig file change + // csharp_style_var_for_built_in_types = false:suggestion to true. + // It should read: csharp_style_var_for_built_in_types = true:suggestion + // Now use (Ctrl k + d) to change types back to var! + var forVarPeople = "Nice!"; + + Console.WriteLine(forVarPeople); + } + + // Click in the if statements and type (Ctrl + .) to invert them. + public void InvertIfElse() + { + var tru = true; + //Bool expressions + if (tru) + { + Console.WriteLine("Truth!"); + } + else + { + Console.WriteLine("Falsehood!"); + } + + // Comparisons + if (1 > 2) + { + Console.WriteLine("Change places!"); + } + else + { + Console.WriteLine("Okay!"); + } + + // Multiple conditions + if (0 == 0 && true || true) + { + Console.WriteLine("AlwaysTrue"); + } + else + { + Console.WriteLine("Unreachable"); + } + } + + // Multi-caret allows you to place multiple cursors in the file + // and edit them all at once. + // Hold down (Ctrl + Alt) and click with the left mouse + // at the beginning of the strings below. Add the word "Hi" + public void MultiCaret() + { + Console.WriteLine("dotnet Bot!"); + Console.WriteLine("Allison!"); + Console.WriteLine("Kendra!"); + } + + // Use a ternary conditional to simplify your code. + // Click inside the if statement and type (Ctrl + .) + // to refactor the if else into a ternary conditional. + public bool TernaryCondition(int two) + { + if (two % 0 == 0) + { + return true; + } + else + { + return false; + } + } + + // You can now add a parameter to a method from a callsite. + // This example involves the two methods below. + // Uncomment the parameter in callMethodA and use the codefix (Ctrl + .) + // to add a string parameter to the MethodA signature. + public void CallMethodA() + { + MethodA(0 /*, "add this parameter"*/); + } + public void MethodA(int zero) + { + + } + + // Place you cursor beside the grayed out parenthesis in the if statement. + // Type (Ctrl + .) to remove the extra parenthesis. + public void RemoveParenthesis() + { + if ((true) && !(2>1)) { } + } + + // Place your cursor in the for loop statement. + // Use (Ctrl + .) to convert it to a foreach loop. + // Use (Ctrl + .) to convert it back into a for loop. + public void ForLoopToForEach() + { + List intList = new List() { 1,2,3}; + + for(int i = 0; i < intList.Count; i++) + { + int num = intList[i]; + Console.WriteLine(intList[num]); + } + } + + // Place you cursor in the linq query of shortGreeting. + // Type (Shift + Alt + plus symbol) to select only the linq query. + // Type (Ctrl + .) to convert the linq query into a foreach loop. + public void LinqToForEach() + { + var greetings = new List() { "hi", "yo", "hello", "howdy" }; + + var shortGreeting = + from greet in greetings + where greet.Length < 3 + select greet; + } + + // Use Go to Enclosing Block to jump to the top of the block your cursor is in. + // Click inside the curly brace below and type (Ctrl + Alt + UpArrow) + // to jump to the top of the class. + } + + // Don't forget you can now navigate to files that you've recently + // viewed with Go To All. Type (Ctrl + t) to bring up the search box. + // Type (r) to view your recent files. Navigate back to Program.cs via the drop down. +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..af32fd0 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Visual Studio 2017 version 15.8 Productivity Features + +## Summary +This repo contains a simple console app that demonstrates several codefixes and refactorings added in Visual Studio 2017 version 15.8. + +- Clone the repo and follow the comments in the code. +- The instructions will require the [Intellicode extension](https://marketplace.visualstudio.com/items?itemName=VisualStudioExptTeam.VSIntelliCode) for Visual Studio. +- You can also view the commit history see what each codefix and refactoring can do. +- Check out the [Visual Studio Productivity guide](aka.ms/vs2017guide) for more features! + +## Features included in tutorial +- Code clean-up (Ctrl + k, d) +- Code cleanup options +- Intellicode +- Invert if (Ctrl + .) +- Multi-caret (Ctrl + alt + click) +- Convert to ternary condition (Ctrl + .) +- Add parameter at callsite (Ctrl + .) +- Erase extra parenthesis (Ctrl + .) +- For loop to foreach (Ctrl + .) +- Linq to ForEach (Ctrl + .) +- Navigate to Enclosing Block (Ctrl + alt + up arrow) +- Go to All Recent Files (Ctrl + t, r) \ No newline at end of file