IntelliTect / IntelliTect/CodingGuidelines
Flag optional arguments on methods that differ from their interface declarations
オープン
@GrantErickson がすでに取り組んでいます。
2020年4月10日 から。
documentation
- 主要言語
- C#
- スター
- 12
- フォーク
- 16
- 平均マージ
- 2分
- マージ済み PR(30日)
- 7
説明
Consider the following case:
public class Foo : IFoo
{
public void Bar(int value = 2) => Console.WriteLine(value);
}
public interface IFoo
{
public void Bar(int value = 1);
}
public static void Main(string[] args)
{
IFoo foo1 = new Foo();
foo1.Bar();
var foo2 = new Foo();
foo2.Bar();
}
Output:
2
1
I would propose that the coding standard be
DO NOT: declare optional arguments on class methods that are implementing an interface.
Rational:
- If these value are not in sync it will cause behavior as shown above.
- It is possible to declare a constant and share it in both places. However, if you have an interface for accessing the class, why is there code bypassing it? If you want to invoke the method using the default value, simply go through the interface.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。