-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-Language DesignFeature RequestLanguage-C#Resolution-Won't FixA real bug, but Triage feels that the issue is not impactful enough to spend time on.A real bug, but Triage feels that the issue is not impactful enough to spend time on.Verification Not Required
Milestone
Description
The human meaning of parameters may vary from method caller's perspective.
It would be useful if the language provides an ability to assign aliases to the parameters.
[Alias({second: [secondAndHalf, quarterToThree], first: [Initial]})]
public static void Member1(string first, string second) {
// Here the user will always use the given names: first and second.
// which means the user cannot use the param by its nickname
// inside the method scope.
}
private static void Caller1() {
Member1(secondAndHalf: "secondly, this is not a bad idea after all",
Initial: "Initially it sounded moot... :) ");
}
private static void Caller2() {
Member1(first: "1st",
quarterToThree: "almost there");
}
private static void Caller3() {
Member1("one", "two");
}vs. this current approach:
public static void Member1(string first, string second) { }
public static void Member1(string first, string secondAndHalf, string devNull = null) {
Member1(first, secondAndHalf);
}Note: the parameter devNull may violate CA1026, in case of overridden methods. On the flip side, setting devNull as non-default parameter would yield "unused parameter".
Related / Real world example: madskristensen/WebEssentials2013#380 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-Language DesignFeature RequestLanguage-C#Resolution-Won't FixA real bug, but Triage feels that the issue is not impactful enough to spend time on.A real bug, but Triage feels that the issue is not impactful enough to spend time on.Verification Not Required