Skip to content

Commit b00d30c

Browse files
sbomerjtschuster
andauthored
Consistently report unresolved members in illink (#103667)
The resolution cache is shared between `Resolve` and `TryResolve`, so we should call `ReportUnresolved` from `Resolve` when we see a cached null result (that could have been cached during `TryResolve`). Should make no difference to supported scenarios because we always run with `IgnoreUnresolved` `true`. This was regressed in dotnet/linker#2253. --------- Co-authored-by: Jackson Schuster <[email protected]>
1 parent b5e6209 commit b00d30c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/tools/illink/src/linker/Linker/LinkContext.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,11 @@ public int GetTargetRuntimeVersion ()
802802
if (methodReference is null)
803803
return null;
804804

805-
if (methodresolveCache.TryGetValue (methodReference, out MethodDefinition? md))
805+
if (methodresolveCache.TryGetValue (methodReference, out MethodDefinition? md)) {
806+
if (md == null && !IgnoreUnresolved)
807+
ReportUnresolved (methodReference);
806808
return md;
809+
}
807810

808811
#pragma warning disable RS0030 // Cecil's resolve is banned -- this provides the wrapper
809812
md = methodReference.Resolve ();
@@ -847,8 +850,11 @@ public int GetTargetRuntimeVersion ()
847850
if (fieldReference is null)
848851
return null;
849852

850-
if (fieldresolveCache.TryGetValue (fieldReference, out FieldDefinition? fd))
853+
if (fieldresolveCache.TryGetValue (fieldReference, out FieldDefinition? fd)) {
854+
if (fd == null && !IgnoreUnresolved)
855+
ReportUnresolved (fieldReference);
851856
return fd;
857+
}
852858

853859
fd = fieldReference.Resolve ();
854860
if (fd == null && !IgnoreUnresolved)
@@ -888,8 +894,11 @@ public int GetTargetRuntimeVersion ()
888894
if (typeReference is null)
889895
return null;
890896

891-
if (typeresolveCache.TryGetValue (typeReference, out TypeDefinition? td))
897+
if (typeresolveCache.TryGetValue (typeReference, out TypeDefinition? td)) {
898+
if (td == null && !IgnoreUnresolved)
899+
ReportUnresolved (typeReference);
892900
return td;
901+
}
893902

894903
//
895904
// Types which never have TypeDefinition or can have ambiguous definition should not be passed in

0 commit comments

Comments
 (0)