C# 7 and .NET Core Cookbook

Book description

Quick solutions to common programming problems with the latest features of C# 7.0, .NET Core 1.1, and Visual Studio 2017

About This Book

  • Easy-to-follow recipes to get you up-and-running with the new features of C# 7 and .NET Core 1.1

  • Practical solutions to assist you with microservices and serverless computing in C#

  • Explore the new Visual Studio environment and write more secure code in it

  • Who This Book Is For

    The book will appeal to C# and .NET developers who have a basic familiarity with C# and the Visual Studio 2015 environment

    What You Will Learn

  • Writing better and less code to achieve the same result as in previous versions of C#

  • Working with analyzers in Visual Studio

  • Working with files, streams, and serialization

  • Writing high-performant code in C# and understanding multi-threading

  • Demystifying the Rx library using Reactive extensions

  • Exploring .Net Core 1.1 and ASP.NET MVC

  • Securing your applications and learning new debugging techniques

  • Designing and building a microservice architecture

  • Using Azure and AWS for serverless computing with C#

  • In Detail

    C# has recently been open-sourced and C# 7 comes with a host of new features for building powerful, cross-platform applications.

    This book will be your solution to some common programming problems that you come across with C# and will also help you get started with .NET Core 1.1. Through a recipe-based approach, this book will help you overcome common programming challenges and get your applications ready to face the modern world.

    We start by running you through new features in C# 7, such as tuples, pattern matching, and so on, giving you hands-on experience with them. Moving forward, you will work with generics and the OOP features in C#. You will then move on to more advanced topics, such as reactive extensions, Regex, code analyzers, and asynchronous programming. This book will also cover new, cross-platform .NET Core 1.1 features and teach you how to utilize .NET Core on macOS. Then, we will explore microservices as well as serverless computing and how these benefit modern developers. Finally, you will learn what you can do with Visual Studio 2017 to put mobile application development across multiple platforms within the reach of any developer.

    Style and approach

    A unique recipe-based guide that will help you gain a solid understanding of the new concepts in C# 7.0 and Visual Studio 2017

    Table of contents

    1. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Sections
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      5. Conventions
      6. Reader feedback
      7. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    2. New Features in C# 7.0
      1. Introduction
      2. Working with Tuples - getting started
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Working with Tuples - going deeper
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Pattern matching
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Out variables
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. Deconstruction
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. Local functions
        1. Getting ready
        2. How to do it...
        3. How it works...
      8. Improvements to literals
        1. Getting ready
        2. How to do it...
        3. How it works...
      9. Ref returns and locals
        1. Getting ready
        2. How to do it...
        3. How it works...
      10. Generalized async return types
        1. Getting ready
        2. How to do it...
        3. How it works...
      11. Expression bodies for accessors, constructors, and finalizers
        1. Getting ready
        2. How to do it...
        3. How it works...
      12. throw expressions
        1. Getting ready
        2. How to do it...
        3. How it works...
    3. Classes and Generics
      1. Introduction
      2. Creating and implementing an abstract class
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Creating and implementing an interface
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Creating and using a generic class or method
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Creating and using a generic interface
        1. Getting ready
        2. How to do it...
        3. How it works...
    4. Object-Oriented Programming in C#
      1. Introduction
      2. Using inheritance in C#
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Using abstraction
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Leveraging encapsulation
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Implementing polymorphism
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. Single responsibility principle
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. Open/closed principle
        1. Getting ready
        2. How to do it...
        3. How it works...
      8. Exception handling
        1. Getting ready
        2. How to do it...
        3. How it works...
    5. Code Analyzers in Visual Studio
      1. Introduction
      2. Finding and installing analyzers
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Creating a code analyzer
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Creating a custom code analyzer
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Deploying your code analyzer within your organization only
        1. Getting ready
        2. How to do it...
        3. How it works...
    6. Regular Expressions
      1. Introduction
      2. Getting started with regex - Matching a valid date
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Sanitizing input
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Dynamic regex matching
        1. Getting ready
        2. How to do it...
        3. How it works...
    7. Working with Files, Streams, and Serialization
      1. Introduction
      2. Creating and extracting ZIP archives
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. In-memory stream compression and decompression
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Async and await file processing
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. How to make a custom type serializable?
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. Using ISerializable for custom serialization to a FileStream
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. Using XmlSerializer
        1. Getting ready
        2. How to do it...
        3. How it works...
      8. JSON serializers
        1. Getting ready
        2. How to do it...
        3. How it works...
    8. Making Apps Responsive with Asynchronous Programming
      1. Introduction
      2. Return types of asynchronous functions
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Handling tasks in asynchronous programming
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Exception handling in asynchronous programming
        1. Getting ready
        2. How to do it...
        3. How it works...
    9. High Performance Programming Using Parallel and Multithreading in C#
      1. Introduction
      2. Creating and aborting a low-priority background thread
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Increasing the maximum thread pool size
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Creating multiple threads
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Locking one thread until the contended resources are available
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. Invoking parallel calls to methods using Parallel.Invoke
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. Using a parallel foreach loop
        1. Getting ready
        2. How to do it...
        3. How it works...
      8. Cancelling a parallel foreach loop
        1. Getting ready
        2. How to do it...
        3. How it works...
      9. Catching errors in parallel foreach loops
        1. Getting ready
        2. How to do it...
        3. How it works...
      10. Debugging multiple threads
        1. Getting ready
        2. How to do it...
        3. How it works...
    10. Composing Event-Based Programs Using Reactive Extensions
      1. Introduction
      2. Installing Rx
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Events versus observables
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Using LINQ to perform queries
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Using schedulers in Rx
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. Debugging lambda expressions
        1. Getting ready
        2. How to do it...
        3. How it works...
    11. Exploring .NET Core 1.1
      1. Introduction
      2. Creating a simple .NET Core application and running it on a Mac
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Creating your first ASP.NET Core application
        1. Getting ready
        2. How to do it...
        3. How it works
      4. Publishing your ASP.NET Core application
        1. Getting ready
        2. How to do it...
        3. How it works...
    12. ASP.NET Core on the MVC Framework
      1. Introduction
      2. Including middleware and why it is useful
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Creating Controllers and using routing
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Rendering Views
        1. Getting ready
        2. How to do it...
        3. How it works...
    13. Choosing and Using a Source Control Strategy
      1. Introduction
      2. Setting up Visual Studio account management and determining which source control solution is best for you
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Setting up Visual Studio GitHub integration, checking in code for the first time, and checking in changes
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Working as a team using GitHub, handling and resolving conflicts in code
        1. Getting ready
        2. How to do it...
        3. How it works...
    14. Creating a Mobile Application in Visual Studio
      1. Introduction
      2. Installing Xamarin and other required components on your Windows PC and Mac
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Creating a mobile application using Apache Cordova
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Creating an iOS application using Xamarin.Forms and Visual Studio for Mac
        1. Getting ready
        2. How to do it...
        3. How it works...
    15. Writing Secure Code and Debugging in Visual Studio
      1. Introduction
      2. Encrypting and storing passwords correctly
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Using SecureString in code
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Securing sensitive parts of the App.config/web.config
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Preventing SQL injection attacks
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. Using IntelliTrace, diagnostic tools, and historical debugging
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. Setting conditional breakpoints
        1. Getting ready
        2. How to do it...
        3. How it works...
      8. Using PerfTips to identify bottlenecks in code
        1. Getting ready
        2. How to do it...
        3. How it works...
    16. Creating Microservices on Azure Service Fabric
      1. Introduction
      2. Downloading and installing Service Fabric
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Creating a Service Fabric application with a stateless actor service
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Using Service Fabric Explorer
        1. Getting ready
        2. How to do it...
        3. How it works...
    17. Azure and Serverless Computing
      1. Introduction
      2. Creating an Azure function
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Providing print functionality with DocRaptor
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Using AWS and S3
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Creating C# Lambda functions with AWS
        1. Getting ready
        2. How to do it...
        3. How it works...

    Product information

    • Title: C# 7 and .NET Core Cookbook
    • Author(s): Dirk Strauss
    • Release date: April 2017
    • Publisher(s): Packt Publishing
    • ISBN: 9781787286276