C#: Address review comments. Create a TNullability type annotation and restructure TAnnotation.

This commit is contained in:
Calum Grant
2019-11-03 15:26:29 +00:00
parent f00276a82c
commit 58e14af9cd
2 changed files with 122 additions and 120 deletions

View File

@@ -7,14 +7,14 @@ namespace Semmle.Extraction.CSharp.Entities
{
public sealed class Nullability
{
public int Annotation { get; private set; }
public int Annotation { get; }
static readonly Nullability[] EmptyArray = new Nullability[0];
public readonly Nullability[] NullableParameters;
public static Nullability Create(AnnotatedTypeSymbol ts)
{
if(ts.HasConsistentNullability())
if (ts.HasConsistentNullability())
{
switch (ts.Nullability)
{
@@ -35,12 +35,6 @@ namespace Semmle.Extraction.CSharp.Entities
static readonly Nullability notannotated = new Nullability(NullableAnnotation.NotAnnotated);
private Nullability(NullableAnnotation n)
{
SetNullability(n);
NullableParameters = new Nullability[0];
}
private void SetNullability(NullableAnnotation n)
{
switch (n)
{
@@ -54,6 +48,7 @@ namespace Semmle.Extraction.CSharp.Entities
Annotation = 0;
break;
}
NullableParameters = EmptyArray;
}
private Nullability(AnnotatedTypeSymbol ts) : this(ts.Nullability)