Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 620ecc8

Browse files
committed
C#: Address review comments part 1.
1 parent 35ecb94 commit 620ecc8

23 files changed

Lines changed: 71 additions & 61 deletions

File tree

change-notes/1.22/analysis-csharp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
* The new class `AnnotatedType` models types with type annotations, including nullability information, return kinds (`ref` and `readonly ref`), and parameter kinds (`in`, `out`, and `ref`)
1818
- The new predicate `Assignable.getAnnotatedType()` gets the annotated type of an assignable (such as a variable or a property)
19-
- The new predicate `Callable.getAnnotatedReturnType()` and `DelegateType.getAnnotatedReturnType()` get the annotated type of the return value
19+
- The new predicates `Callable.getAnnotatedReturnType()` and `DelegateType.getAnnotatedReturnType()` get the annotated type of the return value
2020
- The new predicate `ArrayType.getAnnotatedElementType()` gets the annotated type of the array element
2121
- The new predicate `ConstructedGeneric.getAnnotatedTypeArgument()` gets the annotated type of a type argument
2222
- The new predicate `TypeParameterConstraints.getAnAnnotatedTypeConstraint()` gets a type constraint with type annotations

csharp/extractor/Semmle.Extraction.CSharp/Entities/Constructor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected override void ExtractInitializers()
5757
}
5858

5959
var initInfo = new ExpressionInfo(Context,
60-
new AnnotatedType(initializerType, NullableAnnotation.NotAnnotated),
60+
new AnnotatedType(initializerType, Kinds.TypeAnnotation.NotAnnotated),
6161
Context.Create(initializer.ThisOrBaseKeyword.GetLocation()),
6262
Kinds.ExprKind.CONSTRUCTOR_INIT,
6363
this,

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/ArrayCreation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected override void Populate()
4242

4343
var info = new ExpressionInfo(
4444
cx,
45-
new AnnotatedType(Entities.Type.Create(cx, cx.Compilation.GetSpecialType(Microsoft.CodeAnalysis.SpecialType.System_Int32)), NullableAnnotation.NotAnnotated),
45+
new AnnotatedType(Entities.Type.Create(cx, cx.Compilation.GetSpecialType(Microsoft.CodeAnalysis.SpecialType.System_Int32)), Kinds.TypeAnnotation.NotAnnotated),
4646
Location,
4747
ExprKind.INT_LITERAL,
4848
this,

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Cast.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected override void Populate()
2020
{
2121
// Type conversion
2222
OperatorCall(Syntax);
23-
TypeMention.Create(cx, Syntax.Type, this, Type.Type);
23+
TypeMention.Create(cx, Syntax.Type, this, Type);
2424
}
2525
}
2626

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/ObjectCreation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected override void Populate()
7373
}
7474
}
7575

76-
TypeMention.Create(cx, Syntax.Type, this, Type.Type);
76+
TypeMention.Create(cx, Syntax.Type, this, Type);
7777
}
7878

7979
static SyntaxToken? GetDynamicName(CSharpSyntaxNode name)

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Query.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected Expression DeclareRangeVariable(Context cx, IExpressionParentEntity pa
7171
TypeSyntax declTypeSyntax = null;
7272
if (getElement)
7373
{
74-
if(node is FromClauseSyntax from && from.Type != null)
74+
if (node is FromClauseSyntax from && from.Type != null)
7575
{
7676
declTypeSyntax = from.Type;
7777
declType = Type.Create(cx, cx.GetType(from.Type));

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/This.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class This : Expression
88
This(IExpressionInfo info) : base(info) { }
99

1010
public static This CreateImplicit(Context cx, Type @class, Location loc, IExpressionParentEntity parent, int child) =>
11-
new This(new ExpressionInfo(cx, new AnnotatedType(@class, Microsoft.CodeAnalysis.NullableAnnotation.NotAnnotated), loc, Kinds.ExprKind.THIS_ACCESS, parent, child, true, null));
11+
new This(new ExpressionInfo(cx, new AnnotatedType(@class, Kinds.TypeAnnotation.NotAnnotated), loc, Kinds.ExprKind.THIS_ACCESS, parent, child, true, null));
1212

1313
public static This CreateExplicit(ExpressionNodeInfo info) => new This(info.SetKind(ExprKind.THIS_ACCESS));
1414
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/TypeAccess.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ protected override void Populate()
1717
if (Type.Type.ContainingType == null)
1818
{
1919
// namespace qualifier
20-
TypeMention.Create(cx, maes.Name, this, Type.Type, Syntax.GetLocation());
20+
TypeMention.Create(cx, maes.Name, this, Type, Syntax.GetLocation());
2121
}
2222
else
2323
{
2424
// type qualifier
25-
TypeMention.Create(cx, maes.Name, this, Type.Type);
25+
TypeMention.Create(cx, maes.Name, this, Type);
2626
Create(cx, maes.Expression, this, -1);
2727
}
2828
return;
2929
default:
30-
TypeMention.Create(cx, (TypeSyntax)Syntax, this, Type.Type);
30+
TypeMention.Create(cx, (TypeSyntax)Syntax, this, Type);
3131
return;
3232
}
3333
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/VariableDeclaration.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static VariableDeclaration Create(Context cx, ISymbol symbol, AnnotatedTy
1818
{
1919
LocalVariable.Create(cx, symbol, ret, isVar, declLocation);
2020
if (optionalSyntax != null)
21-
TypeMention.Create(cx, optionalSyntax, parent, type.Type);
21+
TypeMention.Create(cx, optionalSyntax, parent, type);
2222
});
2323
return ret;
2424
}
@@ -135,7 +135,7 @@ public static VariableDeclaration Create(Context cx, CatchDeclarationSyntax d, b
135135
var declSymbol = cx.Model(d).GetDeclaredSymbol(d);
136136
var location = cx.Create(id.GetLocation());
137137
LocalVariable.Create(cx, declSymbol, ret, isVar, location);
138-
TypeMention.Create(cx, d.Type, ret, type.Type);
138+
TypeMention.Create(cx, d.Type, ret, type);
139139
});
140140
return ret;
141141
}
@@ -161,7 +161,7 @@ public static VariableDeclaration CreateDeclarator(Context cx, VariableDeclarato
161161

162162
var decl = d.Parent as VariableDeclarationSyntax;
163163
if (decl != null)
164-
TypeMention.Create(cx, decl.Type, ret, type.Type);
164+
TypeMention.Create(cx, decl.Type, ret, type);
165165
});
166166
return ret;
167167
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public override void Populate()
8282
foreach (var syntax in symbol.DeclaringSyntaxReferences.
8383
Select(d => d.GetSyntax()).OfType<VariableDeclaratorSyntax>().
8484
Select(d => d.Parent).OfType<VariableDeclarationSyntax>())
85-
TypeMention.Create(Context, syntax.Type, this, Type.Type);
85+
TypeMention.Create(Context, syntax.Type, this, Type);
8686
}
8787

8888
readonly Lazy<AnnotatedType> type;

0 commit comments

Comments
 (0)