Training
Module
C# testing in Visual Studio - Training
Start testing your C# apps by using the testing tools in Visual Studio. Learn to write tests, use Test Explorer, create test suites, and apply the red, green, refactor pattern to write code.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The CommunityToolkit.Diagnostics
package contains APIs to efficiently validate method parameters and to throw exceptions in faulting code paths. It is meant to be used to help simplify all argument checks and to make them more expressive and easier to read, while at the same time improving codegen quality and performance.
This package can be installed through NuGet, and it has the following multi-targets:
This means the package can be used on any available runtime (including .NET Framework, .NET Core, UWP, Unity, Xamarin, Uno, Blazor, etc.). The API surface is almost identical in all cases, while the internal implementation can be optimized when newer APIs are available. The Diagnostics package as a whole is meant to be self-contained and extremely small in scope and binary size.
To install the package from within Visual Studio:
In Solution Explorer, right-click on the project and select Manage NuGet Packages. Search for CommunityToolkit.Diagnostics and install it.
Add a using or Imports directive to use the new APIs:
using CommunityToolkit.Diagnostics;
Imports CommunityToolkit.Diagnostics
You can find more examples in the unit tests.
.NET Community Toolkit feedback
.NET Community Toolkit is an open source project. Select a link to provide feedback:
Training
Module
C# testing in Visual Studio - Training
Start testing your C# apps by using the testing tools in Visual Studio. Learn to write tests, use Test Explorer, create test suites, and apply the red, green, refactor pattern to write code.