Share via


IL3003 ‘RequiresAssemblyFilesAttribute’ 주석은 모든 인터페이스 구현 또는 재정의에서 일치해야 합니다.

규칙 ID IL3003
범주 SingleFile
수정이 중단되거나 중단되지 않음 호환성이 손상되지 않음

원인

앱을 단일 파일로 게시하는 경우(예: 프로젝트에서 PublishSingleFile 속성을 true로 설정) [RequiresAssemblyFiles]의 일치하는 주석이 없는 멤버가 포함된 인터페이스 구현 또는 파생 클래스로 인해 다음이 발생할 수 있습니다. 단일 파일과 호환되지 않는 특성을 사용하여 멤버를 호출합니다. 경고가 생성될 수 있는 네 가지 시나리오는 다음과 같습니다.

  • 기본 클래스의 멤버에는 특성이 있지만 파생 클래스의 재정의 멤버에는 특성이 없습니다.

    public class Base
    {
        [RequiresAssemblyFiles]
        public virtual void TestMethod() {}
    }
    public class Derived : Base
    {
        // IL3003: Base member 'Base.TestMethod' with 'RequiresAssemblyFilesAttribute' has a derived member 'Derived.TestMethod()' without 'RequiresAssemblyFilesAttribute'. For all interfaces and overrides the implementation attribute must match the definition attribute.
        public override void TestMethod() {}
    }
    
  • 기본 클래스의 멤버에는 특성이 없지만 파생 클래스의 재정의 멤버에는 특성이 있습니다.

    public class Base
    {
        public virtual void TestMethod() {}
    }
    public class Derived : Base
    {
        // IL3003: Member 'Derived.TestMethod()' with 'RequiresAssemblyFilesAttribute' overrides base member 'Base.TestMethod()' without 'RequiresAssemblyFilesAttribute'. For all interfaces and overrides the implementation attribute must match the definition attribute.
        [RequiresAssemblyFiles]
        public override void TestMethod() {}
    }
    
  • 인터페이스 멤버에는 특성이 있지만 해당 구현에는 특성이 없습니다.

    interface IRAF
    {
        [RequiresAssemblyFiles]
        void TestMethod();
    }
    class Implementation : IRAF
    {
        // IL3003: Interface member 'IRAF.TestMethod()' with 'RequiresAssemblyFilesAttribute' has an implementation member 'Implementation.TestMethod()' without 'RequiresAssemblyFilesAttribute'. For all interfaces and overrides the implementation attribute must match the definition attribute.
        public void TestMethod () { }
    }
    
  • 인터페이스 멤버에는 특성이 없지만 해당 구현에는 특성이 있습니다.

    interface INoRAF
    {
        void TestMethod();
    }
    class Implementation : INoRAF
    {
        [RequiresAssemblyFiles]
        // IL3003: Member 'Implementation.TestMethod()' with 'RequiresAssemblyFilesAttribute' implements interface member 'INoRAF.TestMethod()' without 'RequiresAssemblyFilesAttribute'. For all interfaces and overrides the implementation attribute must match the definition attribute.
        public void TestMethod () { }
    }
    

위반 문제를 해결하는 방법

모든 인터페이스 및 재정의에 대해 구현은 ‘RequiresAssemblyFilesAttribute’ 특성이 있는지 여부와 관련하여 정의와 일치해야 합니다. 두 멤버 모두 특성을 포함하거나 둘 다 포함하지 않습니다. 인터페이스/기본 클래스 멤버 또는 구현/파생 클래스 멤버에서 특성을 제거하거나 추가하여 특성이 둘 다에 있거나 없도록 합니다.

경고를 표시하지 않는 경우

이 경고는 표시하지 않아야 합니다.