際際滷

際際滷Share a Scribd company logo
Writing High Quality Visual Studio Extensions
Omer Raviv | omerr@codevalue.net | @omerraviv
www.oz-code.com | @oz_code
Testable, stable, performant, memory efficient
2
@omerraviv on Twitter (twitter picture)
@omerraviv on Gitter.im/extendvs (Gitter logo)
Omer Raviv
 Creator and CTO of OzCode
 Senior Consultant @ CodeValue
 .NET open-source enthusiast
 Passionate about dev productivity
@omerraviv on Twitter
@omerraviv on Gitter (gitter.im/extendvs)
My Journey as a developer
Every minute
spent in the debugger
is a minute squandered
The two most common ways to use a debugger:
1. Wasting time
2. Quality time
Wasting time:
Not knowing what your hypothesis is at any given time
Getting into a rot mindlessly hitting F10
Quality time:
Apply the Scientific Method, religiously
Simplify the scenario, then write a test!
The Debugging Process Overview
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Why cant
Johnny do Test
Driven
Development?
A typical unit test
Test Driven Woes
2 Unit Tests. 0 Integration Tests.
Creating High Quality Visual Studio extensions
UI
System/
Subcutaneous
Unit
Automation
Harder
Easier
Exploration
Mike Cohns Test
Automation Pyramid
Writing test at the right level of granularity
UI
System/
Subcutaneous
Unit
Exploration
Writing test at the right level of granularity
Microsoft/VisualStudio-TestHost/TestUtilities , PTVS
JaredPar/VsVim/Test
OzCode/VSIntegrationTestSamples
 Synthesis and refinement of practices stemming from TDD & ATDD
 User story:
"As a [role] I want [feature] so that [benefit]
 Acceptance Criteria
Given [initial context]
When [event occurs]
Then [ensure some outcome]
Whats this BDD thing?
Create living, executable
Specification.
New feature?
Can I see the
requirements doc
please?
Whats BDD all about?
 Use natural language to express intentions (GivenWhenThen)
 Use a general purpose programming language
to express test mechanics
 Use a tool that will let you operate in either domain seamlessly
BDD offers a solution
Michael WhelanMehdi Khalili Jake Ginnivan Jason Roberts
PM> Install-Package TestStack.BDDfy
 Works with any testing framework
 Does not require its own test runner
 Creates Humanized, story-like error messages
A few quick BDDfy facts:
Demo time!
Creating High Quality Visual Studio extensions
My very first Visual Studio
Subcutaneous Test
Having flakey tests is a lot worse than having no tests at all.
A flakey test is like a virus 
quarantine it, then triage.
Visual Studio Integration Tests Pro-Tip
Writing High Quality Visual Studio extensions
Omer Raviv | omerr@codevalue.net | @omerraviv
www.oz-code.com | @oz_code
Testable, stable, performant, memory efficient
The ActivityLog.xml
MessageBox
of pain and suffering
The ActivityLog.xml
MessageBox
of pain and suffering github.com/oz-code/OzCode.VisualStudioExtensionAnalyzers
PM> Install-Package OzCode.VisualStudioExtensionAnalyzers
Use an Exception Monitoring Tool
Use an Exception Monitoring Tool
Use an Exception Monitoring Tool
Dealing with crashes
Starting with VS2017.3, users get a notification if an exception might be involved in a crash.
https://gist.github.com/oz-code/76446034c493685bfaabdd5aecc43180
Dealing with crashes
Writing High Quality Visual Studio extensions
Omer Raviv | omerr@codevalue.net | @omerraviv
www.oz-code.com | @oz_code
Testable, stable, performant, memory efficient
Visual Studio 2017 will warn users about extensions that are slowing things down.
Performance as a Feature
1. Delay loading your extension as much as possible (using UIContextRule)
2. When you do load, load in the background. (using AsyncPackage)
Performance as a Feature
OzCode F10 Monkey
http://www.github.com/oz-code/VSExplorationTests
Writing High Quality Visual Studio extensions
Omer Raviv | omerr@codevalue.net | @omerraviv
www.oz-code.com | @oz_code
Testable, stable, performant, memory efficient
Memory Leaks vs. GC Pressure
GC Pressure:
Memory Leak:
Memory Leaks vs. GC Pressure
Pro-Tip: Dont Close your Diagnostics Tools Window!
Dealing with GC Pressure
Memory Leaks vs. GC Pressure
 Always be measuring (allocations, % time spent in GC)
 Watch out for duplicate strings
 Use object pooling / a string intern pool
 Use Roslyn Heap Allocation Analyzer
github.com/jaredpar/vsvim
Memory Leak Testing
Subcutaneous Tests Pro-Tip
Memory Leak Testing
Subcutaneous Tests Pro-Tip
Which means
a business sponsor could request that the current
development version of the software can be deployed
into production at a moment's notice - and nobody
would bat an eyelid, let alone panic.
Got good Subcutaneous Tests?
Start practicing True Continuous Delivery!
Martin Fowler
Thank You!
@oz_code
http://oz-code.com

More Related Content

Creating High Quality Visual Studio extensions

Editor's Notes

  • #33: Roslyn analyzer example, F10 exploration test