- fixes #38818
- setting the *unchanged* scope to non-marked types is harmful,
because in case the type has declaring type, the scope of declaring
type is set as well. see
https://github.com/mono/cecil/blob/master/Mono.Cecil/TypeReference.cs#L132
public virtual IMetadataScope Scope {
get ...
set {
var declaring_type = this.DeclaringType;
if (declaring_type != null) {
declaring_type.Scope = value;
return;
}
scope = value;
}
}
so in our case, we first set correctly scope of
System.Collections.Generic.Dictionary`2 to mscorlib, then (re)set
scope of System.Collections.Generic.Dictionary`2/ValueCollection
and
System.Collections.Generic.Dictionary`2/ValueCollection/Enumerator
to System.Collection (note that these types are not marked and are
swept away by linker), which sets scope of its declaring type
System.Collections.Generic.Dictionary`2 back to System.Collection
and because the System.Collection is linked-out, the typeref is
incorrectly written with the scope set to System later
scope = assembly.MainModule.Import (td).Scope;
if (tr.Scope != scope)
changes = true;
+ hash.Add (tr, scope);
}
- hash.Add (tr, scope);
}
if (assembly.MainModule.HasExportedTypes) {
foreach (var et in assembly.MainModule.ExportedTypes) {