Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
High-Performance Programming in C# and .NET

You're reading from   High-Performance Programming in C# and .NET Understand the nuts and bolts of developing robust, faster, and resilient applications in C# 10.0 and .NET 6

Arrow left icon
Product type Paperback
Published in Jul 2022
Publisher Packt
ISBN-13 9781800564718
Length 660 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Jason Alls Jason Alls
Author Profile Icon Jason Alls
Jason Alls
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Preface 1. Part 1: High-Performance Code Foundation
2. Chapter 1: Introducing C# 10.0 and .NET 6 FREE CHAPTER 3. Chapter 2: Implementing C# Interoperability 4. Chapter 3: Predefined Data Types and Memory Allocations 5. Chapter 4: Memory Management 6. Chapter 5: Application Profiling and Tracing 7. Part 2: Writing High-Performance Code
8. Chapter 6: The .NET Collections 9. Chapter 7: LINQ Performance 10. Chapter 8: File and Stream I/O 11. Chapter 9: Enhancing the Performance of Networked Applications 12. Chapter 10: Setting Up Our Database Project 13. Chapter 11: Benchmarking Relational Data Access Frameworks 14. Chapter 12: Responsive User Interfaces 15. Chapter 13: Distributed Systems 16. Part 3: Threading and Concurrency
17. Chapter 14: Multi-Threaded Programming 18. Chapter 15: Parallel Programming 19. Chapter 16: Asynchronous Programming 20. Assessments 21. Other Books You May Enjoy

Technical requirements

You will need the following prerequisites to complete this chapter:

Obtaining and building the latest Roslyn compiler from the source code

Note

The build system of all .NET-related repositories has been in flux for several years now. We will provide the instructions for compiling Roslyn here; these were correct at the time of writing. For the latest instructions, please read the README.md file located at https://github.com/dotnet/roslyn.

The following instructions are for downloading and building the latest version of the Roslyn compiler source on Windows 10:

  1. In the root of the C:\ drive, clone the Roslyn source code by using the following command in the Windows Command Prompt:
    git clone https://github.com/dotnet/roslyn.git
  2. Then, run the following command:
    cd Roslyn
  3. Restore the Roslyn dependencies by running the following command:
    restore.cmd
  4. Build the Roslyn source code by running the following command:
    build.cmd
  5. Test the Roslyn build by running the following command:
    test.cmd
  6. Once all the tests have finished running, check the versions of C# that are accessible to the new computer. Do this by opening a Command Prompt window and navigating to C:\roslyn\artifacts\bin\csc\Debug\net472.
  7. Then, run the following command:
    csc /langversion:?

    Note

    I always run my Command Prompt as an administrator. Hence, the screenshots will show Command Prompt in administrative mode. But running Command Prompt as an administrator is not necessary for this exercise. Where Command Prompt must be executed as an administrator, this will be made clear as needed.

You should see something equivalent to the following:

Figure 1.1 – The versions of the C# programming language supported by the compiler

Figure 1.1 – The versions of the C# programming language supported by the compiler

As you can see, at the time of writing, version 10.0 of the C# language is available via the C# compiler. C# 10.0 is set as the default. The preview is still under development. The default version may be different on your computer.

Note

The latest version of Visual Studio 2022 should allow you to use the latest available C# 10.0 code features. If it doesn't, then compile the latest source and overwrite the files located at C:\Program Files (x86)\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Roslyn.

The following three sets of instructions provide compiler help for compiling a program that targets a specific C# version and then runs the program. These commands are for demonstrative purposes only, and you do not have to run them now:

csc /help
csc -langversion:10.0 /out:HelloWorld.exe Program.cs
csc HelloWorld

Now that you can build C# 10.0 from the command line and from within Visual Studio 2022, let's learn what kind of new development is taking place with Microsoft .NET 6.

You have been reading a chapter from
High-Performance Programming in C# and .NET
Published in: Jul 2022
Publisher: Packt
ISBN-13: 9781800564718
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime