-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PathAssemblyResolver System.Reflection.MetadataLoadContext should be sealed or allow overrides #36753
Comments
I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label. |
area-System.Reflection |
PR: #36756 |
Due to 5.0 schedule constraints, this is being moved to Future. Normally fields are always private or internal, not public or protected, so to address this scenario we may need to add a property. A workaround is to copy the logic from PathAssemblyResolver into a new class and make necessary changes. |
For the primary proposal: we (generally) don't expose fields as public or protected. For the alternative proposal: we feel that simply exposing the field via a property is still too little abstraction and too limiting on the type. Instead, determine what the use cases are for the extensibility and add protected members to provide that functionality without limiting the implementation details (for example, and add method / remove method / indexer) |
Without knowing the author's exact use-case, I wonder if they could create a "Composite Resolver" that derives from
Sealing |
It seems like I don't yet see a compelling ask for exposing the underlying dictionary for purposes of extending the existing logic. Until we have that, I suggest closing this issue. |
Closing; please re-open if there is a read-world extensibility need for exposing the underlying dictionary in |
_fileToPaths
is markedprivate
with seals all possibilities of extending the class overMetadataAssemblyResolver
.If the intention is to seal the class it should be clear, however i dont think it is appropriate. Instead I think the
_fileToPaths
should be madeprotected
.Another issue worth considering is making
Resolve
code to fail/return fast e.g.if (!_fileToPaths.TryGetValue(assemblyName.Name, out List<string>? paths)) return null;
and that should be checked after theAssert
.API Proposal
Make the field protected
Alternative Designs
Add a property
public class PathAssemblyResolver : MetadataAssemblyResolver { private readonly Dictionary<string, List<string>> _fileToPaths; + protected Dictionary<string, List<string>> FileToPaths => _fileToPaths; }
The text was updated successfully, but these errors were encountered: