Skip to content

Commit

Permalink
Document breaking change for #46044 (#51070)
Browse files Browse the repository at this point in the history
  • Loading branch information
cston authored Mar 9, 2021
1 parent a3afbdb commit 9e43067
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/compilers/CSharp/Compiler Breaking Changes - post DotNet 5.md
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
}
```

0 comments on commit 9e43067

Please sign in to comment.