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
IDE0051 should factor in new dependency attributes in .NET 5 #48206
Comments
@stephentoub Couple of questions to better understand this:
|
Yes. Even outside of the current assembly. So, there are certainly places where there's no way IDE0051 could appropriately respect the attribute (since it can't necessarily see the entire application), and potentially even times when it could theoretically but doing so could be prohibitively expensive. It'd be good, though, if the appropriate thought could be put into if/where/when/how it would make sense, so as to have a complete rather than disjoint story around this kind of trimming / dead-code removal.
@marek-safar, @eerhardt, where is the syntax documented? @Youssef1313, you can use the simple name, in which case it says that all of the overloads should be considered used, or you can name a specific overload by specifying the parameter types, e.g. https://github.com/dotnet/runtime/blob/c44154b15126786260f8a6397248dd04c0e015e3/src/libraries/System.Private.CoreLib/src/System/String.cs#L48
@marek-safar, what does the linker do here? |
Probably the IDE team will want to take this to design meeting to decide what are the essential situations to handle and what are the situations that doesn't need to be handled. |
ILLinker uses the same syntax as Roslyn for documentation so it's documented at https://github.com/dotnet/csharplang/blob/master/spec/documentation-comments.md#processing-the-documentation-file
Not sure why it should be. ILLinker is IL-based tool and the attribute specifies metadata value. |
fwiw, that's challenging as i don't think we have such a concept at all in roslyn. Would it be more appropriate to remove hte 'overload' concept from these strings and say that all dependencies must be individually specified? |
Tagging @sbomer who implemented the parser for the string arguments to DynamicDependencyAttribute in dotnet/linker#1197. @sbomer What is the best way for Roslyn based tooling to convert the string argument to this attribute to Roslyn symbols? Given that the parser you added is adapted from Roslyn's DocumentationCommentId parser, would passing the string to DocumentationCommentId .GetSymbolsForDeclarationId cover all valid allowed values? |
Version Used:
3.9.0-1.20480.1+b3c3f4875957e51526000898673291d11708d35b
Steps to Reproduce:
Expected Behavior:
.NET 5 adds new attributes that enable dependencies not obvious in the code, e.g. those via reflection, to be used for dead code elimination tools like https://github.com/mono/linker to better understand such dependencies. IDE0051 is such a tool and should ideally respect these attributes, such that in this example, IDE0051 doesn't fire.
Actual Behavior:
IDE0051 fires and suggests deleting the "unused" method:
cc: @eerhardt, @NickCraver
The text was updated successfully, but these errors were encountered: