私は、WPF生成されたコードのためのInterfaceMethodsShouldBeCallableByChildTypesを無視するべきですか?

StackOverflow https://stackoverflow.com/questions/351228

  •  20-08-2019
  •  | 
  •  

質問

まだ修正しなければならない単一のウィンドウでWPFアプリケーションのFxCopの1.36を使用する場合は、

、私は次の詳細がInterfaceMethodsShouldBeCallableByChildTypesエラーを取得します:

    Target       : #System.Windows.Markup.IComponentConnector.Connect(System.Int32,System.Object)  (IntrospectionTargetMember)
    Resolution   : "Make 'MainWindow' sealed (a breaking change if 
                   this class has previously shipped), implement the method 
                   non-explicitly, or implement a new method that exposes 
                   the functionality of 'IComponentConnector.Connect(int,
                    object)' and is visible to derived classes."
    Help         : http://msdn2.microsoft.com/library/ms182153(VS.90).aspx  (String)
    Category     : Microsoft.Design  (String)
    CheckId      : CA1033  (String)
    RuleFile     : Design Rules  (String)
    Info         : "Explicit method implementations are defined with private 
                   accessibility. Classes that derive from classes with 
                   explicit method implementations and choose to re-declare 
                   them on the class will not be able to call into the 
                   base class implementation unless the base class has 
                   provided an alternate method with appropriate accessibility. 
                   When overriding a base class method that has been hidden 
                   by explicit interface implementation, in order to call 
                   into the base class implementation, a derived class 
                   must cast the base pointer to the relevant interface.
                    When calling through this reference, however, the 
                   derived class implementation will actually be invoked,
                    resulting in recursion and an eventual stack overflow."
    Created      : 08/12/2008 22:26:37  (DateTime)
    LastSeen     : 08/12/2008 22:41:05  (DateTime)
    Status       : Active  (MessageStatus)
    Fix Category : NonBreaking  (FixCategories)
}

これは単に無視されるべきか?

役に立ちましたか?

解決

これは、すべてのWPFアプリケーションである標準コードであり、あなたは、人々がネットが派生クラスからIComponentConnector.Connectを呼び出すことができることに文句表示されていない、それを無視する - 。それはおそらく安全です。

一般的に、私はあなたが慎重に考慮しなければならないの提案として、FxCopの出力を処理すべきだと思う、私は過去にFxCopのから悪いアドバイスをたくさん持っています。

他のヒント

あなたはinheriterが何を期待するかに依存します。

あなたは、このクラスは、それが密封されるべきとの問題が消えるその後、継承することを期待されていない場合ます。

あなたはそれはあなたがインターフェイスメソッドをオーバーライドし、まだ彼ら(すなわちbase.methodname())を呼び出すための継承クラスの能力を取っている継承されると期待している場合。それはあなたの意思であるならば、あなたは警告を無視することができます。

あなたが公にインターフェイスを公開する必要がありますので、しかし、それは継承クラスのためのありませんの期待される動作である(すなわち、代わりに明示的なインターフェイスの暗黙のインタフェース)。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top