Repository navigation
Support array types in generic parameter - #2576
Conversation
|
Looks like the linker will resolve array type arguments to System.Array: linker/src/linker/Linker.Dataflow/MethodBodyScanner.cs Lines 921 to 930 in 3f704bb (I don't know if we can get there with an array type argument since I think this code might resolve array types to their element type first: linker/src/linker/Linker.Steps/MarkStep.cs Line 2592 in 3f704bb It probably won't make a difference for the analyzer since I don't think System.Array has or will have annotated members, but I think the correct thing to do here to model reflection is to have the array case hit this logic for System.Array: |
| SymbolKind.ErrorType => UnknownValue.Instance, | ||
| // What about things like ArrayType or PointerType and so on. Linker treats these as "named types" since it can resolve them to concrete type | ||
| SymbolKind.ArrayType => new ArrayValue (GetTypeValueNodeFromGenericArgument (((IArrayTypeSymbol) type).ElementType)), | ||
| // What about things like PointerType and so on. Linker treats these as "named types" since it can resolve them to concrete type |
There was a problem hiding this comment.
Since we're here, we should handle these as well - linker resolves pointers and alike to their base element type - so for example "foo *" is resolved to "foo" and then tracked like that. I don't actually know if that is correct from semantics point of view (as in, what will reflection do). So it would be good to figure out the reflection behavior and potentially file an issue against linker as well.
There was a problem hiding this comment.
I don't think pointers can be used as generic arguments, at least in C# - do we even need to handle these?
There was a problem hiding this comment.
That's true, at least for now - I vaguely remember that there's some discussion to allow refs there (reflection could really use this to avoid boxing I think), but I could be wrong.
* First mechanical fix for issue dotnet/linker#2574 * FB * Reverting to the original Commit migrated from dotnet/linker@97cb7eb
Fix for issue #2574,
We create a
SystemTypeValueofSystem.Arrayfor Generic arguments that are ofSymbolKind.ArrayType