-
Notifications
You must be signed in to change notification settings - Fork 457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix oblivious analysis of type parameters #4246
Conversation
5a7d8e1
to
24b7023
Compare
foreach (var typeParameter in typeParameters) | ||
{ | ||
if (ObliviousDetector.CheckTypeParameterConstraints(typeParameter)) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
foreach (var typeParameter in typeParameters) | |
{ | |
if (ObliviousDetector.CheckTypeParameterConstraints(typeParameter)) | |
{ | |
return true; | |
} | |
} | |
return false; | |
return typeParameters.Any(typeParameter => ObliviousDetector.CheckTypeParameterConstraints(typeParameter)); | |
``` #WontFix |
} | ||
|
||
var typeParameters = ((IMethodSymbol)symbol).TypeParameters; | ||
foreach (var typeParameter in typeParameters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same suggestion here. #WontFix
if (symbol.IsReferenceType && | ||
symbol.NullableAnnotation() == NullableAnnotation.None) | ||
{ | ||
// Example: | ||
// I<TReferenceType~> | ||
return true; | ||
} | ||
|
||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (symbol.IsReferenceType && | |
symbol.NullableAnnotation() == NullableAnnotation.None) | |
{ | |
// Example: | |
// I<TReferenceType~> | |
return true; | |
} | |
return false; | |
// Example: | |
// I<TReferenceType~> | |
return symbol.IsReferenceType && | |
symbol.NullableAnnotation() == NullableAnnotation.None; |
{ | ||
// where T : class~ | ||
return true; | ||
} | ||
|
||
foreach (var constraintType in symbol.ConstraintTypes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also be refactored as a .Any()
call. #WontFix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the explicit loop style. One reason is it's easier to step through. #WontFix
C<T> | ||
"; | ||
|
||
await VerifyCSharpAsync(source, shippedText, unshippedText, System.Array.Empty<DiagnosticResult>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious on the why you are passing the empty array. Is it for clarity? Allocation? Something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove. Thanks
Codecov Report
@@ Coverage Diff @@
## master #4246 +/- ##
========================================
Coverage 95.80% 95.81%
========================================
Files 1170 1168 -2
Lines 264491 264737 +246
Branches 15961 15969 +8
========================================
+ Hits 253390 253645 +255
+ Misses 9082 9076 -6
+ Partials 2019 2016 -3 |
Fixes #4040