01

Course Overview

.NET 7.0 is Microsoft’s cross platform, open-source implementation of .NET. It represents the successor to .NET Core, and the unification with the Windows-only .NET Framework. Like .NET Core, .NET 7.0 can run on Windows, Linux, and Mac operating systems, and on a variety of different devices. Similarly, ASP.NET Core 7.0 represents the current and future platform for web applications in .NET and provides cross platform support with flexible hosting options.

This class introduces developers who are already familiar with .NET and web development to the new features introduced in .NET 7.0. The primary emphasis is on presenting what’s new in .NET 7.0 and on highlighting its differences with both .NET Core and .NET Framework. These new features are presented in the context of developing an ASP.NET Core 7.0 Web Api server that is scalable and testable and follows modern best practices.

02

Key Learning Areas

  • Understand the architecture, features and design goals of .NET 7.0
  • Build .NET 7 applications from the command line and Visual Studio
  • Deploy .NET 7 applications, discussing all available models
  • Write code using the new features introduced in C# 9.0/10.0
  • Create an ASP.NET Core 7.0 Web Api server
  • Create an ASP.NET Core 7.0 Web Api server with minimal APIs
  • Configure the ASP.NET Core 7.0 server
  • Abstract the data access details using the repository design pattern
  • Manually create a mock repository
  • Automatically create a mock repository with Moq
  • Inject the repository with ASP.NET Core 7 dependency injection (DI)
  • Unit test code generic code with xUnit
  • Unit test the ASP.NET Core 7 controller with xUnit, DI and Moq
  • Publish the server to the cloud with an Azure App Service
  • Debug the server in production with Windbg and SOS
03

Course Outline

.NET 7.0
The course begins with a general introduction to the motivation and architecture underlying .NET 7.0. This module covers the goals and general features of .NET 7.0, as well as the older technologies that are not ported. A discussion of the .NET versions and release cycles is also covered.

  • What is .NET 7.0 and why write applications for it?
  • Goals
  • General features
  • Technologies not ported to .NET 7.0
  • .NET Releases

Developing a .NET 7.0 Application
The tools for creating, building, and running a .NET 7.0 application are presented, through the use of both the command line and Visual Studio. This module also covers some of the new C# language features that are used by default for the .NET 7.0 code created with Visual Studio, specifically top-level statements, global using directives, and nullable reference types. This module concludes with the details of how to create and use class libraries in .NET 7.0, and the compilation options for building binaries.

  • Developing applications for .NET 7.0
    • Command line/dotnet.exe
    • Visual Studio
  • C# default language features
    • Top-level statements
    • Global using directives
    • Nullable reference types

Deploying a .NET 7.0 Application
After successfully creating and building a .NET 7.0 application, the next step is to publish it for production. .NET 7.0 developers can choose between: (1) a minimal deployment, assuming that everything necessary to run the application is already installed on the client machine, (2) a large, multi-file, self-contained deployment that has everything necessary to run the application on the client machine, or (3) a large, single-file, self-contained deployment. This module demonstrates how to use all three of these options, and their accompanying features, from both the command line and Visual Studio.

  • Deployment models
    • Framework-dependent deployment (FDD)
    • Self-contained deployment (SCE)
      • Trim mode
    • Framework-dependent executables (FDE)
    • Single file executables
  • Compilation options
    • Tired compilation
    • Quick JIT
    • ReadyToRun
  • Libraries for .NET 7.0
    • NuGet Metapackages
    • Distributing a class library through NuGet

ASP.NET Core 7.0
Web development requires an understanding of ASP.NET Core 7.0, and this module thoroughly covers the anatomy of an ASP.NET Core 7.0 application. The internal details of the code generated by the Visual Studio “ASP.NET Core Web Application” project template are covered in depth, specifically WebApplication.CreatetBuilder and all of the other configuration code in the program’s Main. The importance of middleware in writing a modern server application is emphasized, along with how to use existing middleware available through NuGet, and how to write custom middleware. The coverage concludes with a discussion of error handling best practices for development and production builds.

  • Architecture of ASP.NET Core 7.0
  • Hosting options
  • Middleware
  • Error handling

Repository and Unit of Work Patterns
Data access is an essential part of writing any type of application. It is critical that applications follow the established best practices for separating the data access code from the business logic. Providing that separation facilitates changes to the underlying data store and makes the code unit testable. This module presents the two primary design patterns for achieving this proper separation of concerns: The Repository Pattern, for abstracting from the application the details of the data store, and the Unit of Work pattern, for proper access to multiple repositories that share a single context.

  • How to separate application logic from data access
  • Best practices for writing a repository interface
  • Best practices for accessing multiple repositories through Unit of Work

ASP.NET Core 7.0 Web API
This module introduces Web API, the de facto framework for building HTTP-based RESTful services. It covers the motivation for HTTP oriented services as an alternative to SOAP-based services. The architecture of an ASP.NET Core 7.0 Web API application is examined, including convention and attribute-based routing.

  • REST Basics
  • Web API controllers
  • Web API routing
  • CRUD operations

Minimal APIs
One of the most significant new features in ASP.NET Core 7.0 is the introduction of minimal web APIs. This module demonstrates how to use this feature to create HTTP APIs with minimal dependencies for scenarios such as microservices, where it is desirable to use only the minimum files and features from ASP.NET Core.

  • What is a minimal API
  • When should it be used
  • Creating a minimal API with Visual Studio
  • Minimal API generated code
  • CRUD operations

Dependency Injection
Tightly coupled systems are less flexible because they make it difficult to swap out components should they become outdated or need to be replaced.  In addition, the code becomes less testable, because unit tests are unable to replace dependencies with fakes, turning unit tests into integration tests, which are slower and prone to breakage.  This module addresses these issues through the ASP.NET Core 7.0 built-in dependency injection container.

  • Dependency Injection in ASP.NET Core 7.0
  • Constructor and method injection
  • Lifetime models: singleton vs. transient vs. scoped
  • Creating services and injecting them into a web application

ASP.NET Core 7.0 Configuration
ASP.NET Core 7.0 configuration files operate differently from the traditional app.config and web.config files from .NET Framework. In an ASP.NET Core 7.0 application, configuration information is typically specified with json format using an appsettings.json file.  This module demonstrates how configuration files are formatted and parsed in an ASP.NET Core 7.0 application.

  • Initialization and retrieval from the ASP.NET Core 7.0 configuration file
  • Binding and reloading

Unit Testing
Testing is a critical aspect of the software development process, and xUnit is the de facto testing framework for .NET 7.0. This module starts with the definition, best practices, naming conventions, and techniques for unit tests. It then covers the basics of xUnit, highlighting the differences between Fact vs. Theory. The module concludes with a demonstration of how-to unit test the methods of an ASP.NET Core 7.0 controller using manually mocked data.

  • Unit testing fundamentals
  • Using xUnit with Visual Studio
  • Testing code that generates exceptions
  • Testing an ASP.NET Core 7.0 Controller with manual mocking

Mocking with Moq
Test doubles and mocking frameworks make it easier to stub out external dependencies. Moq has emerged as the de facto standard mocking framework for .NET 7.0, and this module covers the details of how to use it to mock interfaces, objects, classes, methods, and properties.

  • State vs Behavior verification
  • The different forms of Test Doubles
  • Moq as an example of a mocking framework
  • Stubs: Properties and Methods
  • Mocks: Strict, Loose and Partial

Unit Testing a Web API Controller using xUnit and Moq
This section represents the culmination of all the material covered in this course.  It shows how to use the techniques previously presented to complete the production of a scalable Web API server that is unit testable and follows modern best practices.  It looks at how to use Dependency Injection and the Repository Pattern for writing controllers that are easier to test, as well as how to use Moq to make it easier to stub out external dependencies.

  • Unit test the methods of an ASP.NET Core 7.0 Web API Controller using xUnit and Moq

Deploying the Server to the Azure cloud
The modern way to deploy an ASP.NET Core 7.0 application is to publish it to the cloud.  This module provides an introduction to the Azure cloud-based deployment options.  It demonstrates how to publish an ASP .NET Core 7.0 application to an App Service in Azure using Visual Studio.  The module concludes with a discussion of the benefits of an Azure deployment, such as scale-up, scale-out, and deployment slots.

  • Introduction to the cloud and Azure
  • Publishing an application to an App Service in Azure
  • The benefits of deploying an application to Azure

C# 9.0-11.0
Accompanying the release of .NET 7.0 is a new release of C#. This module presents C# 9.0-11.0, with features that can make code simpler and clearer through the added language support for immutability and compactness.

  • Init-only properties
  • Record types
  • Record structs
  • Struct improvements
  • Target typing
  • Pattern matching improvements
  • High performance and interop features
  • Coding efficiency features

Migration
This module discusses how to migrate an existing .NET application to .NET 7.0. It presents the options and recommended guidance for porting existing libraries, written for.NET Framework, .NET Core, and .NET Standard, to .NET 7.0. The module concludes with an overview some of the tools that are commonly used to facilitate migrating an application to .NET 7.0.

  • Strategies and tools for porting an existing application
  • .NET Framework technologies discontinued in .NET 7.0
  • Porting from an earlier version of .NET Core to 7.0
  • Porting an ASP.NET Framework Controller to .NET 7.0
  • Porting existing libraries to .NET 7.0
  • Tools for migration
    • Reverse package search
    • NuGet package analyzer
    • API portability analyzer
    • .NET upgrade assistant

Debugging in Production with WinDBG
No network administrator managing production servers is ever going to let you install Visual Studio on a production box. What you are going to get off a production server is a minidump, which is a snapshot of all the memory your .NET application is using. In order to analyze those minidumps, a different debugger is required: WinDBG, the most powerful debugger available on Windows.  In order to debug .NET applications with WinDBG, knowledge of SOS is essential.  SOS is one of those tools that gives you all the power in the world but offers no easy way to get started on using that power.  This module introduces the fundamentals of WinDBG and SOS.

  • The basics of WinDbg
  • WinDbg regular commands for debugging
  • WinDbg meta commands for debugging
  • WinDbg extension commands for debugging
  • Loading and using SOS
  • Process state SOS commands
  • Using SOSEX to fix SOS limitations
  • SOS heap commands
  • Finding reference SOS commands
  • Solving multithreaded deadlocks with SOS and WinDBG
04

Who Benefits

Developers who are already familiar with.NET Framework and/or .NET Core and are looking to: (1) modernize their applications to run on .NET 7.0 and (2) create a testable and scalable ASP.NET Core 7.0 server.

05

Prerequisites

  • .NET Framework or .NET Core programming experience
  • C# programming experience
Want this course for your team?

Atmosera can provide this course virtually or on-site. Please reach out to discuss your requirements.

Atmosera is thrilled to announce that we have been named GitHub AI Partner of the Year.

X