diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/linker/Linker.Dataflow/AttributeDataFlow.cs | 5 | ||||
-rw-r--r-- | src/linker/Linker.Dataflow/CompilerGeneratedCallGraph.cs | 10 | ||||
-rw-r--r-- | src/linker/Linker.Dataflow/CompilerGeneratedState.cs | 12 |
3 files changed, 16 insertions, 11 deletions
diff --git a/src/linker/Linker.Dataflow/AttributeDataFlow.cs b/src/linker/Linker.Dataflow/AttributeDataFlow.cs index 357803a76..3ed11d392 100644 --- a/src/linker/Linker.Dataflow/AttributeDataFlow.cs +++ b/src/linker/Linker.Dataflow/AttributeDataFlow.cs @@ -50,6 +50,9 @@ namespace Mono.Linker.Dataflow MultiValue GetValueForCustomAttributeArgument (CustomAttributeArgument argument) { if (argument.Type.Name == "Type") { + if (argument.Value is null) + return NullValue.Instance; + TypeDefinition? referencedType = ((TypeReference) argument.Value).ResolveToTypeDefinition (_context); return referencedType == null ? UnknownValue.Instance @@ -57,7 +60,7 @@ namespace Mono.Linker.Dataflow } if (argument.Type.MetadataType == MetadataType.String) - return new KnownStringValue ((string) argument.Value); + return argument.Value is null ? NullValue.Instance : new KnownStringValue ((string) argument.Value); // We shouldn't have gotten a non-null annotation for this from GetParameterAnnotation throw new InvalidOperationException (); diff --git a/src/linker/Linker.Dataflow/CompilerGeneratedCallGraph.cs b/src/linker/Linker.Dataflow/CompilerGeneratedCallGraph.cs index 551ff51e5..1cfbc8770 100644 --- a/src/linker/Linker.Dataflow/CompilerGeneratedCallGraph.cs +++ b/src/linker/Linker.Dataflow/CompilerGeneratedCallGraph.cs @@ -9,15 +9,15 @@ namespace Mono.Linker.Dataflow { sealed class CompilerGeneratedCallGraph { - readonly Dictionary<IMemberDefinition, HashSet<IMemberDefinition>> callGraph; + readonly Dictionary<IMemberDefinition, HashSet<IMemberDefinition>> _callGraph; - public CompilerGeneratedCallGraph () => callGraph = new Dictionary<IMemberDefinition, HashSet<IMemberDefinition>> (); + public CompilerGeneratedCallGraph () => _callGraph = new Dictionary<IMemberDefinition, HashSet<IMemberDefinition>> (); void TrackCallInternal (IMemberDefinition fromMember, IMemberDefinition toMember) { - if (!callGraph.TryGetValue (fromMember, out HashSet<IMemberDefinition>? toMembers)) { + if (!_callGraph.TryGetValue (fromMember, out HashSet<IMemberDefinition>? toMembers)) { toMembers = new HashSet<IMemberDefinition> (); - callGraph.Add (fromMember, toMembers); + _callGraph.Add (fromMember, toMembers); } toMembers.Add (toMember); } @@ -48,7 +48,7 @@ namespace Mono.Linker.Dataflow visited.Add (start); queue.Enqueue (start); while (queue.TryDequeue (out IMemberDefinition? method)) { - if (!callGraph.TryGetValue (method, out HashSet<IMemberDefinition>? callees)) + if (!_callGraph.TryGetValue (method, out HashSet<IMemberDefinition>? callees)) continue; foreach (var callee in callees) { diff --git a/src/linker/Linker.Dataflow/CompilerGeneratedState.cs b/src/linker/Linker.Dataflow/CompilerGeneratedState.cs index 2802e6703..c99968f1d 100644 --- a/src/linker/Linker.Dataflow/CompilerGeneratedState.cs +++ b/src/linker/Linker.Dataflow/CompilerGeneratedState.cs @@ -102,7 +102,7 @@ namespace Mono.Linker.Dataflow /// up and find the nearest containing user type. Returns the nearest user type, /// or null if none was found. /// </summary> - TypeDefinition? PopulateCacheForType (TypeDefinition type) + TypeDefinition? GetCompilerGeneratedStateForType (TypeDefinition type) { // Look in the declaring type if this is a compiler-generated type (state machine or display class). // State machines can be emitted into display classes, so we may also need to go one more level up. @@ -183,7 +183,7 @@ namespace Mono.Linker.Dataflow } // Already warned above if multiple methods map to the same type // Fill in null for argument providers now, the real providers will be filled in later - _ = _generatedTypeToTypeArgumentInfo.TryAdd (stateMachineType, new TypeArgumentInfo (method, null)); + _generatedTypeToTypeArgumentInfo[stateMachineType] = new TypeArgumentInfo (method, null); } } @@ -292,6 +292,7 @@ namespace Mono.Linker.Dataflow if (typeRef is null) { return; } + for (int i = 0; i < typeRef.GenericArguments.Count; i++) { var typeArg = typeRef.GenericArguments[i]; // Start with the existing parameters, in case we can't find the mapped one @@ -321,6 +322,7 @@ namespace Mono.Linker.Dataflow typeArgs[i] = userAttrs; } + _generatedTypeToTypeArgumentInfo[generatedType] = typeInfo with { OriginalAttributes = typeArgs }; } } @@ -356,7 +358,7 @@ namespace Mono.Linker.Dataflow if (IsNestedFunctionOrStateMachineMember (method)) return false; - var typeToCache = PopulateCacheForType (method.DeclaringType); + var typeToCache = GetCompilerGeneratedStateForType (method.DeclaringType); if (typeToCache is null) return false; @@ -371,7 +373,7 @@ namespace Mono.Linker.Dataflow { Debug.Assert (CompilerGeneratedNames.IsGeneratedType (generatedType.Name)); - var typeToCache = PopulateCacheForType (generatedType); + var typeToCache = GetCompilerGeneratedStateForType (generatedType); if (typeToCache is null) return null; @@ -407,7 +409,7 @@ namespace Mono.Linker.Dataflow // sourceType is a state machine type, or the type containing a lambda or local function. // Search all methods to find the one which points to the type as its // state machine implementation. - var typeToCache = PopulateCacheForType (sourceType); + var typeToCache = GetCompilerGeneratedStateForType (sourceType); if (typeToCache is null) return false; |