Skip to content

Commit 9e43067

Browse files
authored
Document breaking change for #46044 (#51070)
1 parent a3afbdb commit 9e43067

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## This document lists known breaking changes in Roslyn after .NET 5.
2+
3+
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 `?`.
4+
```C#
5+
static void F1<T>(object? obj)
6+
{
7+
T t1 = default; // warning CS8600: Converting possible null value to non-nullable type
8+
t1 = (T)obj; // warning CS8600: Converting possible null value to non-nullable type
9+
10+
T? t2 = default; // ok
11+
t2 = (T?)obj; // ok
12+
}
13+
```

0 commit comments

Comments
 (0)