-
Notifications
You must be signed in to change notification settings - Fork 473
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
Continue analysis even RuntimeInformation, OSPlatofrm types not loaded #4281
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4281 +/- ##
=========================================
Coverage ? 95.80%
=========================================
Files ? 1168
Lines ? 265259
Branches ? 15985
=========================================
Hits ? 254143
Misses ? 9095
Partials ? 2021 |
...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
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 LGTM, have some trivial suggestions.
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.
Is it possible to add a test to avoid any regression?
...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
...ft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.GuardedCallsTests.cs
Outdated
Show resolved
Hide resolved
...ft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.GuardedCallsTests.cs
Outdated
Show resolved
Hide resolved
I have tested runtime build by enabling the analyzer when other types ( While doing that test found a bug: IOOB exception thrown when the OSPlatform type is not loaded which is silently swallowed by the IDE and no more diagnostics take place. Fixed the bug, now this PR is ready for merge @mavasani if you would like to take another look |
Gonna merge it now if there are any questions/comments feel free to add, will apply/answer then separately |
As part of dotnet/runtime#42335 we need to ensure that each of runtime projects can produce warnings/errors from the platform compat analyzer during a normal build. There are several projects not having access to the System.Runtime.InteropServices.RuntimeInformation, System.Runtime.InteropServices.OSPlatofrm which are used as one of the guard methods for the analzyer. Normally we bail out when any of the types used for the analysis is not loaded/found, but the types mentioned are not essential for the analysis we want to continue the analysis in that case and get warnings if there is any.