Josh Heitzman - Senior Software Design Engineer

Slides:



Advertisements
Similar presentations
Boost Writing better code faster with Boost. Boost Introduction Collection of C++ libraries Boost includes 52 libraries, 1.31 will have at least.
Advertisements

Microsoft Office SharePoint Portal Server 2007 Introduction to InfoPath Forms Services Daryl L. Rudolph.
Microsoft SharePoint 2010 technology for Developers
Designing, Deploying and Managing Workflow in SharePoint Sites Steve Heaney Product Development Manager OBS
COM vs. CORBA.
Visual Studio Extensibility, DSL Tools and T4 Code Generation Peter Goodman.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Best Practices for Interop with Visual C++ Boris Jabes Program Manager Microsoft Corporation.
API Design CPSC 315 – Programming Studio Fall 2008 Follows Kernighan and Pike, The Practice of Programming and Joshua Bloch’s Library-Centric Software.
Advanced Object-Oriented Programming Features
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Scott Grissom, copyright 2004Ch 3: Java Features Slide 1 Why Java? It is object-oriented provides many ready to use classes platform independent modern.
Guide To UNIX Using Linux Third Edition
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Tahir Nawaz Visual Programming C# Week 2. What is C#? C# (pronounced "C sharp") is an object- oriented language that is used to build applications for.
ACM/JETT Workshop - August 4-5, 2005 UML Modeling using MagicDraw UML for Java Programmers.
Using Microsoft SharePoint to Develop Workflow and Business Process Automation Ted Perrotte National Practice Manager, Quilogy, Microsoft Office SharePoint.
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
KEAN UNIVERSITY Visual C++ Dr. K. Shahrabi. Developer studio Is a self-contain environment for creating, compiling, linking and testing windows program.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
ESB Guidance 2.0 Kevin Gock
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
Lesley Bross, August 29, 2010 ArcGIS 10 add-in glossary.
ASP.NET  ASP.NET is a web development platform, which provides a programming model, a comprehensive software infrastructure and various services required.
Future Directions: Building Customizable Applications using.NET Eric Schnepp TLN205 Lead Program Manager Microsoft Corporation.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
Getting Started The structure of a simple wxWidgets program, Look at where and how a wxWidgets application starts and ends, how to show the main window,
2. Introduction to the Visual Studio.NET IDE. Chapter Outline Overview of the Visual Studio.NET IDE Overview of the Visual Studio.NET IDE Menu Bar and.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Managed C++. Objectives Overview to Visual C++.NET Concepts and architecture Developing with Managed Extensions for C++ Use cases Managed C++, Visual.
Ni.com Understanding COM/ActiveX Jeff Paulter Staff Software Engineer Thurs Aug 17 10:15-11:30 a.m., 1:45-3:00 p.m. Ash (10A) Jeff Paulter Staff Software.
Lecture 11 Dynamic link libraries. Differences between static libraries and DLLs In static library code is added to the executable. In DLL, the code is.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Eagle: Maturation and Evolution 17th Annual Tcl Conference Joe Mistachkin.
Office Business Applications Workshop Defining Business Process and Workflows.
Microsoft Visual Basic 2005 BASICS Lesson 1 A First Look at Microsoft Visual Basic.
Taking Control of Visual Studio through Extensions and Extensibility Anthony Cangialosi Senior Program Manager Lead Microsoft Corporation DEV311.
Digging into the GAT API Comparing C, C++ and Python API‘s Hartmut Kaiser
Teach.NET Workshop Series Track 4: AP Computer Science with.NET and J#
® IBM Software Group © 2007 IBM Corporation Module 1: Getting Started with Rational Software Architect Essentials of Modeling with IBM Rational Software.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Revisiting building. Preprocessing + Compiling 2 Creates an object file for each code file (.c ->.o) Each.o file contains code of the functions and structs.
Best 5 Mobile App Development Tools for Developer's to think beyond the Limitation.
Pyragen A PYTHON WRAPPER GENERATOR TO APPLICATION CORE LIBRARIES Fernando PEREIRA, Christian THEIS - HSE/RP EDMS tech note:
Enterprise Library 3.0 Memi Lavi Solution Architect Microsoft Consulting Services Guy Burstein Senior Consultant Advantech – Microsoft Division.
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
Self-Contained Systems
Excel Tutorial 8 Developing an Excel Application
Windows Programming Environments
Vytautas Traškevičius Software Engineering
Chapter 2: The Visual Studio .NET Development Environment
Test-driven development
Before You Begin Nahla Abuel-ola /WIT.
DotnetConf 9/10/2018 7:49 PM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE.
Interface Definition Language
Enterprise Library Overview
C Basics.
Module 1: Getting Started
null, true, and false are also reserved.
Hands-on Introduction to Visual Basic .NET
CIS16 Application Development Programming with Visual Basic
MIX 09 12/8/2018 4:33 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Eagle: Maturation and Evolution
Active Template Library
Microsoft Consumer Channels and Central Marketing Group
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2006
Presentation transcript:

Josh Heitzman - Senior Software Design Engineer VSL Deep Dive Josh Heitzman - Senior Software Design Engineer

VSL is… Acronym for “Visual Studio Library” Modern C++ library targeting the Visual Studio Platform. Styled after ATL and WTL. Comprised only of header files. No binaries. Extensible and customizable (macros can be overriden to change core behavior). Not a framework like MFC, MPF, .Net Framework, etc.. Not a complete offering for the entire VS Platform

VSL Effect Code Lines Comment Lines Characters Semi-colons Functions Feature equivalent C++ Tool Window 828 508 53,858 228 34 C# Tool Window 844 724 63,686 433 49 C++ Menus & Commands 178 222 18,996 38 11 C# Menus & Commands 227 201 20,498 90 10 C++ Services 315 320 28,230 78 15 C# Services 270 289 26,773 101 13 C++ Single View Editor 2,653 1,203 130,689 879 142 C# Single View Editor 3,253 1,620 251,990 1,147 276 Not feature equivalent C++ Package 81 13,648 7 3 C# Package 204 261 22,284 72 17

Resources <SDK Root>\VisualStudioIntegration\Common\Source\CPP\VSL VSLArchitecture.htm – class diagrams Include – VSL header files MockInterfaces – Windows and Visual Studio Platform Interface mocks UnitTest\VSLUnitTest.sln – solution with all of the VSL unit tests. Questions/Issues: http://forums.microsoft.com/msdn/showforum.aspx?forumid=57&siteid=1 Prefix post title with “VSL” Feedback/Suggestions: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=123359&SiteID=1 Blog: http://blogs.msdn.com/josh_heitzman/

VSL Design Principles Minimize coupling Avoid feature creep Exploit the C++ language and the Microsoft Visual C++ compiler Facilitate unit testing Re-use without obstruction Responsive to requests

Minimize coupling Narrowly scoping the functionality of classes: Implement one interface Wrap one VS Service Wrap one related set of Win32 APIs Use of C++ templates to reduce hard dependencies between classes. template< class Derived_T, class VsSiteCache_T = VsSiteCacheLocal> class IVsWindowPaneImpl : public IVsWindowPane template <class Derived_T> class IExtensibleObjectImpl : public IExtensibleObject

Avoid feature creep Only the functionality required for the task at hand is implemented. Avoid investing resources in features that may not be needed. class VsOutputWindowUtilities { void OutputMessage( const wchar_t* const szMessage); OutputMessageWithPreAndPostBarsOfEquals( };

Exploit the C++ language and the Visual C++ compiler When possible, fail at compile time rather then runtime Make use of C++ exceptions Use C++ templates and when necessary C pre-processor macros to minimize code redundancy and maximize reuse Use of an extended version of the Resource Allocation Is Initialization paradigm template < class Type_T, size_t NumberOfElements_T> class StaticArray { C_ASSERT( NumberOfElements_T > 0); … __if_exists(Derived_T::GetViewObject) __if_exists(Derived_T:: GetLocalRegistryCLSIDViewObject) // Can't speceify both an object and // a clsid C_ASSERT(0); } pViewObject = rDerived.GetViewObject();

Resource Allocation Is Initialization (RAII) RAII is used with all resources to ensure their lifetime is properly managed in the face of exceptions. template <...> class Resource { ResourceType m_Resource; Resource(): m_Resource(Values::GetNullValue()) {} Resource(ResourceType resource): m_Resource(resource) ~Resource() Free(); } void Free(); ResourceType Detach(); operator CastType() const; };

eXtendened Resource Allocation Is Initialization (XRAII) class Suspend { Suspend(This& rThis): m_rThis(rThis) m_rThis.SendMessage(WM_SETREDRAW, FALSE, 0); m_dwMaskToRestore = static_cast<DWORD>(m_rThis.SendMessage( EM_SETEVENTMASK, 0, ENM_NONE)); } ~SuspendDrawAndNotifications() m_rThis.SendMessage( EM_SETEVENTMASK, 0, m_dwMaskToRestore); m_rThis.SendMessage(WM_SETREDRAW, TRUE, 0); This& m_rThis; DWORD m_dwMaskToRestore; }; RAII is extended to any set of calls that need balancing.

Facilitate unit testing Mocks for nearly all VS Platform interfaces Mocks for many Windows Platform interfaces Wrapper classes around some sets of Win32 APIs Mocks for those classes Cursor CursorMock File FileMock Keyboard KeyboardMock Window WindowMock

Re-use without obstruction Many classes take template parameters Allows you to provide your own custom implementation for a dependency Some template defaults will be correct for 99% of cases A couple of classes using policy based design a smart pointer and a smart resource Optional statically bound call backs into a derived class This is accomplished via __if_exists and __if_notexists Numerous macros that can be overridden

Responsive to requests VS SDK release cycle is short CTP monthly RTW every 4 months Designs are never perfect the first time Even more so when on short cycle Breaking changes will be made as the demand arises Short cycle means there won’t be a lot of BCs with any given release

VSL provides help with… Error and exception handling Unit testing Functors and delegates Comparing various things Managing resources The basics necessary to create a VS Package Command handling VS Service consumption Creating a VS Window that hosts a dialog or Win32 control Creating a VS Document / VS Editor Automation and VS Macro recording VS Hierarchies

Error and exception handling Error handling macros that convert errors to exceptions Exception handling macros that catch and convert exceptions to HRESULTs VSL_BEGIN_MSG_MAP – message map that catches exceptions Header files: VSLErrorHandlers.h VSLExceptionHandlers.h VSL_STDMETHODTRY{ VSL_CHECKHANDLE_GLE(::GetDC(hWnd)); }VSL_STDMETHODCATCH() return VSL_GET_STDMETHOD_HRESULT();

Unit testing Unit testing framework Mocks for nearly all VS Platform interfaces Mocks for many Windows Platform interfaces Mocks for wrapper classes around some sets of Win32 APIs Including some of ATL::CWindow Header files: VSLUnitTest.h class UnitTest : public UnitTestBase { UnitTest( const char* const szTestName): UnitTestBase(szTestName) UTCHK(false); } }; int _cdecl _tmain(int, _TCHAR*) UTRUN(UnitTest); return VSL::FailureCounter::Get();

Functors and delegates Classes: Functor FunctionPointerFunctor MemberFunctionPointerFunctor Delegate Header Files: VSLCommon.h FunctionPointerFunctor<void ()> functor(&OnEvent1); Delegate<void ()> event1; event1 += functor; event1(); event1 -= functor();

Comparing various things Implemented primarily for the interface mocks IsStringLessThen can be used with STL algorithms Header files: VSLComparison.h

Managing resources Policy based resource managers: Header files: Pointer Resource Header files: VSLCommon.h VSLFont.h typedef Pointer<CoTaskMemPointerTraits> CoTaskMemPointer; CoTaskMemPointer pBuffer = ::CoTaskMemAlloc(iBufferByteSize); CHKPTR(static_cast<LPVOID>(pBuffer), E_OUTOFMEMORY); CHK(0 == ::memcpy_s(pBuffer, iBufferByteSize, GetFileName(), iBufferByteSize), E_FAIL); *ppszFilename = static_cast<LPOLESTR>(pBuffer.Detach());

The basics necessary to create a VS Package Classes: IVsPackageImpl IVsInstalledProductImpl Registry map macros Header files: VSLPackage.h class Package : public IVsPackageImpl< Package, &CLSID_Package>, public IVsInstalledProductImpl< IDS_PRODUCT_NAME, IDS_PRODUCT_IDENTIFIER, IDS_PRODUCT_DETAILS, IDI_ LOGO> { VSL_BEGIN_REGISTRY_MAP(IDR_PACKAGE_RGS) ... VSL_END_REGISTRY_MAP()

VsSiteCache Can be local or global IVsPackageImpl uses the global VsSiteCache by default Once a package is sited anything can then use the global cache by creating an instance of VsSiteCacheGlobal or utilizing the static methods of VsIServiceProviderUtilities directly or via the macros: VSQS - VsIServiceProviderUtilities<>::QueryService VSQCS - VsIServiceProviderUtilities<>::QueryCachedService IVsPaneWindow uses the local VsSiteCache by default Once window is sited can correctly get context sensitive services like SID_STrackSelection and SID_SVsWindowFrame

Command handling Classes: Header files: Samples: IOleCommandTargetImpl Command map macros VsFontCommandHandling Header files: VSLCommandTarget.h Samples: Menus and Commands Services Tool Window Single View Editor class MenuAndCommandsPackage : ... public IOleCommandTargetImpl< MenuAndCommandsPackage>, VSL_BEGIN_COMMAND_MAP() VSL_COMMAND_MAP_ENTRY( GUID_MenuAndCommandsCmdSet, cmdidMyCommand, NULL, &MenuCommandCallback) VSL_COMMAND_MAP_ENTRY_WITH_FLAGS( cmdidDynVisibility2, NULL, &MenuVisibilityCallback, OLECMDF_SUPPORTED | OLECMDF_ENABLED | OLECMDF_INVISIBLE) VSL_END_VSCOMMAND_MAP()

VS Service consumption Header files: VSLPackage.h Samples: Menus and Command Services Tool Window Single View Editor Wrapped VS Services: VsOutputWindowUtilities ProfferServiceUtilities OleComponentUIManagerUtilities Can use global or local VsSiteCache. OleComponentUIManagerUtilities<>::ShowMessage( L"Title", L"Message");

Creating a VS Window that hosts a dialog Classes: IVsWindowPaneImpl Window VsWindowPaneFromResource Header files: VSLWindows.h class Form : public VsWindowPaneFromResource< Form, MAKEINTRESOURCE(IDD_DLG)>

Creating a VS Window that hosts a Win32 control Classes: IVsWindowPaneImpl Window ListViewWin32Control RichEditWin32Control Win32ControlContainer Header files: VSLControls.h VSLWindows.h class Document : public Win32ControlContainer< RichEditWin32Control<> > class Report : ListViewWin32Control< ReportViewTraits< false, false> > >

Fully integrating a VS Window Classes VsWindowFrameEventSink ISelectionContainerImpl ISelectionContainerSingleItemImpl Header files VSLWindows.h class WindowPane : public IVsWindowPaneImpl<WindowPane>, public VsWindowFrameEventSink<WindowPane>, public ISomeInterface, public ISelectionContainerSingleItemImpl< WindowPane, ISomeInterface>

Creating a VS Document / VS Editor Classes: IVsEditorFactoryImpl IVsFindTargetImpl SingleViewFindInFilesOutputWindowIntegrationImpl File DocumentPersistanceBase Header Files: VSLFile.h VSLFindAndReplace.h VSLWindow.h Samples: Single View Editor

Automation and VS Macro recording Classes: IExtensibleObjectImpl VsMacroRecorder Header Files: VSLAutomation.h Samples: Single View Editor void RecordCommand( wchar_t* szCommand) { if(m_Recorder.IsRecording( GetVsSiteCache())) CStringW strLine = L"ActiveDocument.Object."; strLine += szCommand; m_Recorder.RecordLine( strLine); }

IVsHierarchyEventsDelegate VsHierarchyRootItemBase VsHierarchyItemBase Classes: IVsHierarchyImpl IVsUIHierarchyImpl IVsHierarchyEventsDelegate VsHierarchyRootItemBase VsHierarchyItemBase VsUIHierarchyItemBase HierarchyNode C++ Interfaces: IVsHierarchyItem IVsUIHierarchyItem IVsHierarchyRootItem IVsUIHierarchyRootItem Header Files: VSLHierarchy.h VSLHierarchyNode.h Samples: Extensiblity Explorer

Miscellaneous Win32 Resource Managers/Wrappers Classes: Library – HMODULE’s from ::LoadLibrary DeviceContext – HDC’s from ::GetDC Cursor – HCURSOR from ::LoadCursor Keyboard These classes only provide what was necessary for the reference samples, but can be easily expanded as needed. For example: Library has no methods (just constructor/destructor) DeviceContext only has EnumFontFamiliesExW Cursor only has Activate Keyboard only has IsKeyDown

Data Collection Do you: Have existing packages written in C++? Use VSL in C++ packages? Plan to use VSL in C++ packages in the future? Unit test existing C++ packages? Use VSL for unit testing C++ packages? Plan to use VSL for unit testing C++ packages in the future? Plan to write new packages in C++ in the future? What kind of package (project system, editor, designer, etc.)? Plan to expand add additional features in C++? What type of features? Want better tools for creating scenario tests? Want sample scenario tests?

Data Collection continued Plan to migrate existing C++ package to managed? C++/CLI? C#? Other? Over what time frame?