-
Notifications
You must be signed in to change notification settings - Fork 466
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
Flag when platform specific type used as generic type parameter #4403
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4403 +/- ##
========================================
Coverage 95.80% 95.81%
========================================
Files 1174 1174
Lines 267562 267805 +243
Branches 16097 16105 +8
========================================
+ Hits 256351 256601 +250
+ Misses 9145 9137 -8
- Partials 2066 2067 +1 |
@jeffhandley confirmed that we want it for 5.0.2xx and we have a separate issue for tracking inheritance related scenarios, I think this PR good to go now @mavasani please take another look |
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
.../UnitTests/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.cs
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
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.
Overall looking good - want to make sure that we handle field/property/event access off a generic type with disallowed type argument. Looks good to sign off once that is addressed. Thanks!
...ft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.GuardedCallsTests.cs
Show resolved
Hide resolved
...tAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs
Outdated
Show resolved
Hide resolved
var containingSymbol = context.ContainingSymbol; | ||
if (containingSymbol is IMethodSymbol method && method.IsAccessorMethod()) | ||
{ | ||
containingSymbol = method.AssociatedSymbol; |
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.
As we are not adding parent attributes to the accessor methods so that it will not report a duplicate warning when the containing symbol had any attribute (for example property has no accessor level attribute but the entire property has attribute). But when the property getter or setter any statements inside it became the containing symbol for those statements. When accessors used as call site, as their attributes are not including the parent attributes call site attributes are incomplete and causing warnings. So here when accessor is the containing symbol change it to the AssociatedSymbol which is the real Property or Event which has complete attributes for call site
Retargeted to master, as there is no any other change merging |
Warn when platform-specific type used as generic type parameter, useful when a type created using reflections
Fixes #4362
Cherry-picked from #4390 to target
release\5.0.2xx
branch