You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I thought parameters starting with _ would be tolerated (i.e. would not raise an error) as of #244 / 0001c0c . There's even a test at the end of the commit!
Context: we're developing some Unity project, and it's well known for adding magic methods to do custom behaviors without explicitly implementing C# interfaces. For instance, this function would be invoked after assets have been loaded, and it needs four/five arguments, but we may not use all of them. Even with underscores, errors are raised.
So this MR fixes the case when parameter name consists of one or more underscores.
Parameter starting with underscore is a different case. It's definitely possible to suppress RCS1163 for this case. The question is whether is it a common convention that unused parameter's name should start with underscore. Maybe it would be better to create editorconfig option for it.
Ha, I misread that commit. Meanwhile, I just learned that this case, variable names with only underscores, is a convention in Dart. Also I just discovered that built-in rule IDE0060 silences _, and _ followed by digits.
Roslynator wouldn't complain, but I'd do. I prefer to keep the original names around to know what they are about and why I've chosen not to use them, especially since they are all of the same type. Arguably, with a good test coverage and documentation, it may be redundant.
IMHO prefixing unused symbols with an underscore is a common convention, at least in Rust, TypeScript, Python... I even remember that with one language, actually using such a parameter triggers a linter error, because you're using a parameter that is not supposed to be used, so as to force you to drop the leading underscore.
I can't tell about adding this feature in here or in editorconfig.
I thought about it and I would say that current implementation is fine as a default.
If anybody would be interested I would implement it as a opt-in, i.e. add editorconfig option that will cause that parameters whose name starts with underscore won't be reported as unused.
Hi,
I thought parameters starting with
_
would be tolerated (i.e. would not raise an error) as of #244 / 0001c0c . There's even a test at the end of the commit!Context: we're developing some Unity project, and it's well known for adding magic methods to do custom behaviors without explicitly implementing C# interfaces. For instance, this function would be invoked after assets have been loaded, and it needs four/five arguments, but we may not use all of them. Even with underscores, errors are raised.
I'm using Roslynator.Analyzers version 4.3.0. This happens both with roslynator version 0.9.3.0 and with dotnet (format) version 7.0.410.
The text was updated successfully, but these errors were encountered: