문제

아직 수정되지 않은 단일 창이있는 WPF 애플리케이션에 FXCOP 1.36을 사용하는 경우 다음 세부 사항에 따라 인터페이스 메토드 SHOULDSHOULDBECLODYLDTYPES 오류가 발생합니다.

    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로부터 많은 나쁜 조언을 받았습니다.

다른 팁

상속자가 할 것으로 기대하는 것에 따라 다릅니다.

이 클래스가 상속받을 것으로 기대하지 않으면 봉인되고 문제가 사라져야합니다.

상속받을 것으로 기대하고 있다면 상속 클래스의 능력을 인터페이스 메소드를 무시하고 여전히 호출 할 수 있습니다 (예 : base.methodname()). 그것이 당신의 의도라면 경고를 무시할 수 있습니다.

그러나 그것은입니다 ~ 아니다 상속 가능한 클래스의 예상 동작이므로 인터페이스를 공개적으로 노출시켜야합니다 (즉, 명시 적 인터페이스 대신 암시 적 인터페이스).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top