Download presentation
Presentation is loading. Please wait.
Published byEthan Morris Modified over 8 years ago
1
Toni Petrina Microsoft MVP for C# Ekobit d.o.o. Controlling and extending development environment
2
Turn off your mobile. Thank you.
3
3 Agenda Intro Extending your code Snippets, Item, Project Templates, T4-templates Extending your reach Custom NuGet repository, Private Extension Galleries Extending your environment Visualizers, Add-Ins, The future – Roslyn, Browser Link Summary
4
4 Problem?
5
5 Every scrum iteration... You tend to forget that churning code should be optimized too Tooling Rules Policies
6
6 Problems we run into High cost of training newcomers High cost of maintenance Adding new features takes too long Legacy apps are more of a frameworks
7
7 Patterns, patterns everywhere
8
8 Organization MyCompany.Interfaces MyCompany.Models MyCompany.ViewModels MyCompany.Views MyCompany.Utilities MyCompany.DataProviders MyCompany.MockDataProviders MyCompany.UnitTests
9
9 Why extend Familiar environment Don’t leave Visual Studio Bring your tools inside Enhance productivity Reduce repetitiveness Copy/paste pattern can introduce errors Become VSIP Sell extensions through Extension Galleries
10
Extending your code
11
11 Repetitive code I’ve seen this code before DRY – don’t repeat yourself applies to creating properties in code too Golden rule – if you wrote it twice, you’ll probably write it again Size matters For reusing smaller fragments of code – snipets For reusing file/class/interface structure – item templates For reusing entire project structure – project templates Sometimes code even needs to be generated – T4 text templates Sharing VSIX – for item/project templates (and snippets) VSI – for snippets
12
12 Snippets Create and reuse snippets Just a.snippet file Creating them manually is tedious Snippet Designer to the rescue Excellent for idioms Share snippets Copy/paste Shared folder Distribute via Visual Studio Content Installer
13
13 Snippets
14
14 Item templates Common scenarios - You need a license header - Complex inheritance - Forcing comments - You need items for your custom framework i.e. non-coding files: localization, resources, business logic - Replace default items - Complex item creation via wizard Advanced Multi-file item templates Distribute via VSIX
15
15 Project templates Common scenarios You need a project template for your company (setting up common stuff) Your application is actually a set of project templates (thing app/add-in generators) Starter kit Third-party controls provider offering template with initial settings MEF, Localization, Dependency Injection, Resources, etc. When Item Templates are not good enough Advanced Add wizards for custom Distribute via VSIX
16
16 Item/Project template
17
17 T4 text templates Common scenarios Complex code generation when item template is not good enough Localization (generate from UI components) Designers (model, database, UI) Imports from other project outputs (e.g. XML) Legacy bindings (language bindings) Help/static documents generator Code changes during development or between versions Testing scenarios Advanced Run time generation (e.g. reports) Distribute via VSIX
18
18 T4-templates
19
Extending your reach
20
20 Private Extension Galleries Distributing - licensed extensions - in-house extensions - Project/Item templates Works in intranet environments Integrate with CI to create custom distribution channels E.g. for testers Can be administrated via registry
21
21 Private Extension Galleries
22
22 Custom NuGet repository Works in intranet environments Hosting options - Shared folder - IIS host
23
23 Private Extension Galleries
24
Extending your environment
25
25 Why would I build extensions Customize IDE Keybindings, tools customization Custom content New components, domain specific Automation Speed up development and/or deployment Replace or add new features New platforms, language support, integration with other services
26
26 Sky is the limit Enhance your productivity Custom tooling Refactoring Custom editors (useful for DSLs) Custom languages Add help for your development environment Apply company- or team-wide standards Less code reviews Policies become effective
27
27 Sky is the limit (2) Connect with outside tools Database ERP Testing/Staging environments Third-party apps for content creation Visual Studio as a platform
28
28 Visualizer Debugging made easy Specific types for your projects Build better visualizers for the BCL or FCL classes Easily extensible Supports editing Custom forms Custom controls Don’t forget: inherit ISerializable
29
29 Visualizer
30
30 Creating VS add-ins You will need Visual Studio 2012 SDK* http://www.microsoft.com/en-us/download/details.aspx?id=30668 Or use the Extensions and Updates dialog * This depends on the version of Visual Studio you are building your extensions for
31
31 Creating VS add-ins Launch in new Visual Studio instance No conflicts with the existing environment Supported languages C#, Visual Basic, C++ Default template Menu command Tool windows Custom editor
32
32 Add-in
33
33 Looking for inspiration? Lots of add-ins are open source Learn from them Interesting ideas Notable examples NuGet WebEssentials 2012/2013 Snippet Designer http://code.msdn.microsoft.com/
34
Extensions that understand your code
35
35 Roslyn Compiler as a Service
36
36 Roslyn Latest version is September 2012 CTP http://go.microsoft.com/fwlink/?LinkID=228400 Work in progres Entire compiler pipeline is available
37
37 Types of extensions Code Issue Info, warning or error Code refactoring Offer refactoring Completion provider Custom completion Outliner For custom structures
38
38 Roslyn extensions
39
39 Distributing add-ins VSIX files Pack all MEF or other components into a single installer Distribute via Extension Gallery Sell, distribute, open source... Easy to version and upgrade
40
40 Browser Link Part of Visual Studio 2013 Itself an extension Open source Source code at github https://github.com/madskristensen/WebEssentials2013https://github.com/madskristensen/WebEssentials2013 Don’t forget to install Visual Studio 2013 SDK http://www.microsoft.com/visualstudio/eng/2013- downloads#d-additional-softwarehttp://www.microsoft.com/visualstudio/eng/2013- downloads#d-additional-software Extendible extension MEF components Two-part extension: one for Visual Studio, another for the browser
41
41 Browser Link
42
42...and beyond Powershell extensions for Visual Studio Custom processing Complex item creation/manipulation Build extensions Custom content generation Custom steps Deploy to internal gallery/nuget integration
43
43 Summary Remember, DRY Reuse code as snippets or templates Generate code that you don’t want to write Integrate tools that will help you do your job Private repositories/galleries For companies VSIP partnership and monetization opportunities Sell extensions
44
Q&A.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.