-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
docs/compilers/CSharp/Compiler Breaking Changes - post DotNet 5.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## This document lists known breaking changes in Roslyn after .NET 5. | ||
|
||
1. https://github.com/dotnet/roslyn/issues/46044 In C# 9.0 (Visual Studio 16.9), a warning is reported when assigning `default` to, or when casting a possibly `null` value to a type parameter type that is not constrained to value types or reference types. To avoid the warning, the type can be annotated with `?`. | ||
```C# | ||
static void F1<T>(object? obj) | ||
{ | ||
T t1 = default; // warning CS8600: Converting possible null value to non-nullable type | ||
t1 = (T)obj; // warning CS8600: Converting possible null value to non-nullable type | ||
T? t2 = default; // ok | ||
t2 = (T?)obj; // ok | ||
} | ||
``` |