2

まだ変更されていない単一のウィンドウを持つWPFアプリケーションにFxCop1.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)
}

これは単に無視する必要がありますか?

4

2 に答える 2

0

無視してください。これはすべての WPF アプリケーションに含まれる標準コードであり、派生クラスから IComponentConnector.Connect を呼び出すことができる net について不平を言う人はいないので、おそらく安全です。

一般に、FxCop の出力は慎重に検討する必要がある提案として扱うべきだと思います。過去に FxCop から多くの悪いアドバイスを受けました。

于 2008-12-09T08:52:30.083 に答える
0

継承者に何を期待するかによって異なります。

このクラスが継承されることを期待していない場合は、封印する必要があり、問題は解決します。

継承されることを期待している場合は、継承クラスの機能を利用して、インターフェイス メソッドをオーバーライドし、引き続きそれらを呼び出すことができます (つまりbase.methodname())。それがあなたの意図であれば、警告を無視することができます。

ただし、これは継承可能なクラスの予期される動作ではないため、インターフェイスをパブリックに公開する必要があります (つまり、明示的なインターフェイスではなく暗黙的なインターフェイス)。

于 2008-12-09T01:23:39.100 に答える