Mastering C# and .NET Framework

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Author(s): Marino Posadas
Publisher: Packt

Language: English

Cover
Copyright
Credits
About the Author
Acknowledgements
About the Reviewer
www.PacktPub.com
Table of Contents
Preface
Chapter 1: Inside the CLR
An annotated reminder of some important computing terms
Context
The OS multitask execution model
Context types
Thread safety
State
Program state
Serialization
Process
Thread
SysInternals
Static versus dynamic memory
Garbage collector
Concurrent computing
Parallel computing
Imperative programming
Declarative programming
The evolution of .NET
.NET as a reaction to the Java World
The open source movement and .NET Core
Common Language Runtime
Common Intermediate Language
Managed execution
Components and languages
Structure of an assembly file
Metadata
Introducing metadata with a basic Hello World
PreJIT, JIT, EconoJIT, and RyuJIT
Common Type System
A quick tip on the execution and memory analysis of an assembly in Visual Studio 2015
The stack and the heap
Garbage collection
Implementing algorithms with the CLR
Data structures, algorithms, and complexity
Big O Notation
Relevant features appearing in versions 4.5x, 4.6, and .NET Core 1.0 and 1.1
.NET 4.5.x
.NET 4.6 (aligned with Visual Studio 2015)
.NET Core 1.0
.NET Core 1.1
Summary
Chapter 2: Core Concepts of C#
and .NET
C# – what's different in the language?
Languages: strongly typed, weakly typed, dynamic, and static
The main differences
The true reason for delegates
The evolution in versions 2.0 and 3.0
Generics
Creating custom generic types and methods
Lambda expressions and anonymous types
Lambda expressions
The LINQ syntax
LINQ syntax is based on the SQL language
Deferred execution
Joining and grouping collections
Type projections
Extension methods
Summary
Chapter 3: Advanced Concepts of
C# and .NET
C# 4 and .NET framework 4.0
Covariance and contravariance
Covariance in interfaces
Covariance in generic types
Covariance in LINQ
Contravariance
Tuples: a remembrance
Tuples: implementation in C#
Tuples: support for structural equality
Tuples versus anonymous types
Lazy initialization and instantiation
Dynamic programming
Dynamic typing
The ExpandoObject object
Optional and named parameters
The Task object and asynchronous calls
C# 5.0: async/await declarations
What's new in C# 6.0
String interpolation
Exception filters
The nameof operator
The null-conditional operator
Auto-property initializers
Static using declarations
Expression bodied methods
Index initializers
What's new in C# 7.0
Binary literals and digit separators
Pattern matching and switch statements
Tuples
Decomposition
Local functions
Ref return values
Summary
Chapter 4: Comparing Approaches for Programming
Functional languages
F# 4 and .NET Framework
The inevitable Hello World demo
Identifiers and scope
Lists
The TypeScript language
The new JavaScript
TypeScript: a superset of JavaScript
So, what exactly is TypeScript?
Main features and coalitions
Installing the tools
Transpiling to different versions
Advantages in the IDE
A note on TypeScript's object-oriented syntax
More details and functionality
Summary
Chapter 5: Reflection and Dynamic Programming
Reflection in the .NET Framework
Calling external assemblies
Generic Reflection
Emitting code at runtime
The System.CodeDOM namespace
The Reflection.Emit namespace
Interoperability
Primary Interop Assemblies
Formatting cells
Inserting multimedia in a sheet
Interop with Microsoft Word
Office apps
The Office app default project
Architectural differences
Summary
Chapter 6: SQL Database Programming
The relational model
Properties of relational tables
The tools – SQL Server 2014
The SQL language
SQL Server from Visual Studio
Data access in Visual Studio
.NET data access
Using ADO.NET basic objects
Configuring the user interface
The Entity Framework data model
Summary
Chapter 7: NoSQL Database Programming
A brief historical context
The NoSQL world
Architectural changes with respect to RDBMS
Querying multiple queries
The problem of nonnormalized data
Data nesting
About CRUD operations
MongoDB on Windows
File structure and default configuration
Some useful commands
Altering data – the rest of CRUD operations
Text indexes
MongoDB from Visual Studio
First demo: a simple query from Visual Studio
CRUD operations
Deletion
Insertion
Modifications and replacements
Summary
Chapter 8: Open Source Programming
Historical open source movements
Other projects and initiatives
Open source code for the programmer
Other languages
The Roslyn project
Differences from traditional compilers
Getting started with Roslyn
A first look at Microsoft Code Analysis Services
Code Analyzers
An entire open source sample for you to check: ScriptCS
A basic project using Microsoft.CodeAnalysis
The first approach to code refactoring
Debugging and testing the demo
TypeScript
Debugging TypeScript
Debugging TypeScript with Chrome
Interfaces and strong typing
Implementing namespaces
Declarations, scope, and Intellisense
Scope and encapsulation
Classes and class inheritance
Functions
Arrays and interfaces
More TypeScript in action
The DOM connection
Summary
Chapter 9: Architecture
The election of an architecture
The Microsoft platform
A universal platform
The MSF application model
The Team Model
The Governance Model
The Risk Model
Risk evaluation
Risk assessment
Risk action plans
CASE tools
The role of Visio
A first example
The database design
Creating the demo application in Visual Studio
Website design
Reports
Many other options
BPMN 2.0 (Business Process Model and Notation)
UML standard support
Visual Studio architecture, testing, and analysis tools
Application's architecture using Visual Studio
Class diagrams
Testing
Testing our application in Visual Studio
The Analyze menu
The end of the life cycle: publishing the solution
Summary
Chapter 10: Design Patterns
The origins
The SOLID principles
Single Responsibility principle
An example
Open/Closed principle
Back to our sample
Liskov Substitution principle
Back to the code again
Other implementations of LSP in .NET (Generics)
Interface Segregation principle
Dependency Inversion principle
A final version of the sample
Design patterns
Singleton
The Factory pattern
The Adapter pattern
The Façade pattern
The Decorator pattern
The Command pattern
An example already implemented in .NET
The Observer pattern
The Strategy pattern
Other software patterns
Other patterns
Summary
Chapter 11: Security
The OWASP initiative
The OWASP Top 10
A1 – injection
SQL injection
Prevention
The case for NoSQL databases
A2 – Broken Authentication and Session Management
The causes
Prevention
.NET coding for A2
Desktop applications
Web applications
A3 – Cross-Site Scripting (XSS)
Prevention
A4 – Insecure Direct Object References
Prevention
A5 – Security Misconfiguration
Possible examples of attacks
Prevention – aspects to consider
Prevention – measures
A6 – Sensitive Data Exposure
A7 – Missing Function-level Access Control
Prevention
A8 – Cross-Site Request Forgery
Prevention
A9 – Using components with known vulnerabilities
A10 – Invalidated redirects and forwards
Summary
Chapter 12: Performance
Application Performance Engineering
The tools
Advanced options in Visual Studio 2015
Other tools
The process of performance tuning
Performance Counters
Bottleneck detection
Using code to evaluate performance
Optimizing web applications
IIS optimization
ASP.NET optimization
Summary
Chapter 13: Advanced Topics
The Windows messaging subsystem
The MSG structure
Sub-classing techniques
Some useful tools
Platform/Invoke: calling the OS from .NET
The process of platform invocation
Windows Management Instrumentation
Parallel programming
Difference between multithreading and parallel programming
Parallel LINQ
Dealing with other issues
Canceling execution
The Parallel class
The Parallel.ForEach version
Task Parallel
Communication between threads
.NET Core 1.0
The list of supported environments
Core FX
Core CLR
Core RT
Core CLI
Installation of .NET Core
The CLI interface
ASP.NET Core 1.0
What's new
A first approach
Configuration and Startup settings
Self-hosted applications
ASP.NET Core 1.0 MVC
Managing scripts
NET Core 1.1
Summary
Index