C#: C#8 Nullable expressions and type annotations#1408
C#: C#8 Nullable expressions and type annotations#1408aibaars merged 13 commits intogithub:masterfrom
Conversation
|
This pull request introduces 3 alerts and fixes 1 when merging e219a77 into c03e804 - view on LGTM.com new alerts:
fixed alerts:
This project has automated code review enabled, but doesn't use the LGTM GitHub App. Migrate over by installing the app. Read about the benefits of migrating to GitHub Apps in the blog. Comment posted by LGTM.com |
| @@ -0,0 +1,17 @@ | |||
| import csharp | |||
|
|
|||
| query predicate suppressNullableWarnings(SuppressNullableWarningExpr e, Expr op) { | |||
There was a problem hiding this comment.
Need to add an exclusion in the nullness library that this is a non-null expression.
| * 1 = not null | ||
| * 2 = may be null | ||
| */ | ||
| nullable_flow_state(unique int expr: @expr ref, int value: int ref); |
There was a problem hiding this comment.
Delete this for now.
| int id: @type_parameter_constraints ref, | ||
| int base_id: @type_or_ref ref); | ||
| int base_id: @type_or_ref ref, | ||
| int nullability: int ref); |
There was a problem hiding this comment.
nullability -> annotation
There was a problem hiding this comment.
Maybe this should live on the side, for example
specific_type_parameter_annotation(id, base_id, annotation);
|
|
||
| /** The nullability of type arguments of a constructed type or method. */ | ||
| #keyset[constructedgeneric, position] | ||
| nullable_type_arguments(int constructedgeneric: @generic ref, int position: int ref, int nullability: int ref); |
There was a problem hiding this comment.
generalize, nullability -> annotation
| Console.WriteLine(x); | ||
| } | ||
|
|
||
| string? field3; |
| @@ -0,0 +1,144 @@ | |||
| /** | |||
| * Provides predicates classes for representing the nullability of various C# declarations. | |||
There was a problem hiding this comment.
Generalize this to type annotations.
There was a problem hiding this comment.
Including ref and out
|
|
||
| module Nullability { | ||
| /** Holds if the flow state of the expression has determined that `e` may be null. */ | ||
| predicate exprMayBeNull(Expr e) { nullable_flow_state(e, 2) } |
| } | ||
|
|
||
| private newtype TAnnotatedType = | ||
| TAnnotatedTypeNullability(Type type, int nullability) { |
There was a problem hiding this comment.
Generalize this, to string, string? ref, string ref, string?
Don't just talk about Nullability.
There was a problem hiding this comment.
Represent this as a set of integer, represented as a bit field.
| class AnnotatedType extends TAnnotatedType { | ||
| Type underlyingType; | ||
|
|
||
| int nullability; |
There was a problem hiding this comment.
Change this to annotation, and predicate predicate hasAnnotation(TypeAnnotation a). Maybe an IPA type for now.
|
|
||
| /** Gets the annotated type of element `e`. */ | ||
| cached | ||
| AnnotatedType getAnnotatedType(Element e) { |
There was a problem hiding this comment.
library predicate
|
This pull request introduces 1 alert and fixes 1 when merging eb20d64 into 7790ac4 - view on LGTM.com new alerts:
fixed alerts:
This project has automated code review enabled, but doesn't use the LGTM GitHub App. Migrate over by installing the app. Read about the benefits of migrating to GitHub Apps in the blog. Comment posted by LGTM.com |
eb20d64 to
d9e6602
Compare
|
This pull request introduces 1 alert and fixes 1 when merging d9e6602 into 41d5d5a - view on LGTM.com new alerts:
fixed alerts:
This project has automated code review enabled, but doesn't use the LGTM GitHub App. Migrate over by installing the app. Read about the benefits of migrating to GitHub Apps in the blog. Comment posted by LGTM.com |
|
This pull request introduces 1 alert and fixes 1 when merging 01895bb into 41d5d5a - view on LGTM.com new alerts:
fixed alerts:
This project has automated code review enabled, but doesn't use the LGTM GitHub App. Migrate over by installing the app. Read about the benefits of migrating to GitHub Apps in the blog. Comment posted by LGTM.com |
|
|
||
| /** Holds if this callable returns a `ref readonly`. */ | ||
| predicate returnsRefReadonly() { ref_readonly_returns(this) } | ||
| deprecated predicate returnsRefReadonly() { |
There was a problem hiding this comment.
Say what to use instead.
01895bb to
4356cbd
Compare
hvitved
left a comment
There was a problem hiding this comment.
First review of the dbscheme changes, and (light) review of AnnotatedType.qll. I really like the design 👍
e8a1288 to
6c12c88
Compare
a458f40 to
e60ae58
Compare
hvitved
left a comment
There was a problem hiding this comment.
Truly awesome stuff, Calum. As I have said earlier, I really like the type annotation design in QL.
csharp/extractor/Semmle.Extraction.CSharp/Kinds/TypeAnnotation.cs
Outdated
Show resolved
Hide resolved
8d154c4 to
fc15412
Compare
…_type_parameter_annotation on the side of specific_type_parameter_constraints.
…they can be deduced.
…e predicates in TypeParameterConstraints.
fc15412 to
76454ed
Compare
|
This pull request introduces 1 alert and fixes 1 when merging 76454ed into 1a9f362 - view on LGTM.com new alerts:
fixed alerts:
|
|
This pull request introduces 1 alert and fixes 1 when merging 2504754 into 7ff6d82 - view on LGTM.com new alerts:
fixed alerts:
|
hvitved
left a comment
There was a problem hiding this comment.
LGTM, just two small comments.
| override UnboundGenericType getUnboundGeneric() { constructed_generic(this, getTypeRef(result)) } | ||
|
|
||
| language[monotonicAggregates] | ||
| string annotatedTypeArgumentsToString() { |
|
|
||
| namespace Semmle.Extraction.Kinds | ||
| { | ||
| [Flags] |
There was a problem hiding this comment.
Where is it used like a flag set in the code?
There was a problem hiding this comment.
It isn't, currently, however it is "morally" a set and could be used in that way.
|
This pull request introduces 1 alert and fixes 1 when merging 4d38300 into a554369 - view on LGTM.com new alerts:
fixed alerts:
|
|
The related internal PR has been merged. |
No description provided.