- https://github.com/dotnet/roslyn/issues/21485 In Roslyn 2.0, the `unsafe` modifier could be used on a local function without using the `/unsafe` flag on the compilation. In Roslyn 2.6 (Visual Studio 2017 verion 15.5) the compiler requires the `/unsafe` compilation flag, and produces a diagnostic if the flag is not used.
- https://github.com/dotnet/roslyn/issues/20210 In C# 7.2, there are some uses of the new pattern switch construct, in which the switch expression is a constant, for which the compiler will produce warnings or errors not previously produced.
> ``` c#
> switch (default(object))
> {
> case bool _:
> case true: // new error: case subsumed by previous cases
> case false: // new error: case subsumed by previous cases
> break;
> }
>
> switch (1)
> {
> case 1 when true:
> break;
> default:
> break; // new warning: unreachable code
> }
> ```
- https://github.com/dotnet/roslyn/issues/22578 In C# 7.1, the compiler would compute the wrong default value for an optional parameter of nullable type declared with the default literal. For instance, `void M(int? x = default)` would use `0` for the default parameter value, instead of `null`. In C# 7.2 (Visual Studio 2017 version 15.5), the proper default parameter value (`null`) is computed in such cases.
\ No newline at end of file
``` c#
switch(default(object))
{
casebool_:
casetrue:// new error: case subsumed by previous cases
casefalse:// new error: case subsumed by previous cases
break;
}
switch(1)
{
case1whentrue:
break;
default:
break;// new warning: unreachable code
}
```
- https://github.com/dotnet/roslyn/issues/20103 In C# 7.2, when testing a constant null expression against a declaration pattern in which the type is not inferred, the compiler will now warn that the expression is never of the provided type.
``` c#
constobjecto=null;
if(oisobjectres){// warning CS0184: The given expression is never of the provided ('object') type
```
- https://github.com/dotnet/roslyn/issues/22578 In C# 7.1, the compiler would compute the wrong default value for an optional parameter of nullable type declared with the default literal. For instance, `void M(int? x = default)` would use `0` for the default parameter value, instead of `null`. In C# 7.2 (Visual Studio 2017 version 15.5), the proper default parameter value (`null`) is computed in such cases.