This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
Special case MakeGenericMethod/Type in RUC analyzer - #2209
Merged
Merged
Conversation
vitek-karas
reviewed
Aug 13, 2021
| { | ||
| if (member is IMethodSymbol method && ImmutableArrayOperations.Contains (specialIncompatibleMembers, member, SymbolEqualityComparer.Default)) { | ||
| if (method.Name == "MakeGenericType") { | ||
| operationContext.ReportDiagnostic (Diagnostic.Create (s_makeGenericTypeRule, operationContext.Operation.Syntax.GetLocation (), method.GetDisplayName ())); |
Member
There was a problem hiding this comment.
I wonder if we should simply not warn here.
The guiding principal for the analyzer should be:
"If the analyzer produces a warning -> linker will also produce that warning"
In this case this will now hold - linker has more complex handling of MakeGenericType/Method which will avoid warning in many cases. The analyzer would warn every time. I would much rather we special case this and not warn for now, until we can build enough smarts in the analyzer to match the linker behavior.
/cc @sbomer - we discussed the general behavior, so for context.
added 2 commits
September 3, 2021 14:22
mateoatr
force-pushed
the
makeGenericWarnings
branch
from
September 3, 2021 21:50
5903c6e to
3dc2dca
Compare
vitek-karas
approved these changes
Sep 7, 2021
| { | ||
| if (member is IMethodSymbol method && ImmutableArrayOperations.Contains (specialIncompatibleMembers, member, SymbolEqualityComparer.Default) && | ||
| (method.Name == "MakeGenericMethod" || method.Name == "MakeGenericType")) { | ||
| return true; |
Member
There was a problem hiding this comment.
Can you please add a comment why we're doing this?
agocke
pushed a commit
to dotnet/runtime
that referenced
this pull request
Nov 16, 2022
…2209) * Add MakeGenericMethod and MakeGenericType to the special incompatible members of the RUC analyzer. * Don't produce diagnostics for MakeGenericMethod/MakeGenericType * Add comment * Lint Commit migrated from dotnet/linker@8b7695a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now that
MakeGenericMethodandMakeGenericTypemethods were annotated in the runtime, we need to special case these in the analyzer to emit the right warning (IL2060 and IL2055, respectively).