disable warning CA1062 by using C#8 beta nullable ref types

https://github.com/MicrosoftDocs/visualstudio-docs/issues/3588
This commit is contained in:
Collin M. Barrett 2019-07-05 14:18:24 -05:00
parent 1611b53a0f
commit 2892cd655a
3 changed files with 5 additions and 4 deletions

View file

@ -7,9 +7,7 @@ public static class ReadOnlyListExtensions
{
public static T FirstOrDefault<T>(this IReadOnlyList<T> list)
{
if (list is null)
throw new ArgumentNullException(nameof(list));
return list.Count == 0 ? default : list[0];
return list.Count == 0 ? default! : list[0];
}
}
}

View file

@ -4,7 +4,9 @@
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<LangVersion>latest</LangVersion>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<NullableContextOptions>enable</NullableContextOptions>
<Authors>Collin M. Barrett</Authors>
<Company>Collin M. Barrett</Company>
<Product>FilterLists</Product>

View file

@ -13,6 +13,7 @@
<Rule Id="CA1049" Action="Warning" />
<Rule Id="CA1060" Action="Warning" />
<Rule Id="CA1061" Action="Warning" />
<Rule Id="CA1062" Action="None" />
<Rule Id="CA1063" Action="Warning" />
<Rule Id="CA1065" Action="Warning" />
<Rule Id="CA1301" Action="Warning" />