다음을 통해 공유


IL(중간 언어) 출력에서 플래그 또는 옵션을 생성하는 사용자 지정 특성

컴파일러가 지정된 IL(중간 언어) 한정자를 내보내도록 코드에 이러한 특성을 추가합니다. 이러한 특성은 출력에 해당 IL 한정자를 포함하도록 컴파일러에 지시합니다.

속성 수식어 코멘트
System.Runtime.InteropServices.ComImportAttribute import
System.Runtime.InteropServices.DllImportAttribute pinvokeimpl 생성자에 나열된 옵션을 추가할 수 있습니다.
System.Runtime.InteropServices.FieldOffsetAttribute .field 그러면 메모리 레이아웃의 필드 오프셋이 설정됩니다.
MarshalAsAttribute marshal 생성자에 나열된 옵션을 설정할 수 있습니다.
System.Runtime.CompilerServices.MethodImplAttribute flag 생성자 인수는 aggressiveinlining 또는 forwardref같은 특정 명명된 플래그를 지정합니다. 또한 이러한 플래그는 native 필드에 대한 managed, optil또는 System.Runtime.CompilerServices.MethodCodeType 한정자를 지정합니다.
System.NonSerializedAttribute notserialized
System.Runtime.InteropServices.OptionalAttribute [opt]
System.Runtime.InteropServices.PreserveSigAttribute preservesig
System.SerializableAttribute serializable
System.Runtime.InteropServices.StructLayoutAttribute auto, sequential또는 explicit 매개 변수를 사용하여 레이아웃 옵션을 설정할 수 있습니다.
System.Runtime.CompilerServices.IndexerNameAttribute 이 특성을 인덱서에 추가하여 다른 메서드 이름을 설정합니다. 기본적으로 인덱서는 Item속성으로 컴파일됩니다. 이 특성을 사용하여 다른 이름을 지정할 수 있습니다.

이러한 사용자 지정 특성 중 일부는 소스 코드에 특성을 추가하는 대신 다른 C# 구문을 사용하여 적용됩니다.

속성 코멘트
System.Runtime.InteropServices.DefaultParameterValueAttribute 매개 변수의 기본값을 지정합니다. 기본 매개 변수 구문사용합니다.
System.Runtime.InteropServices.InAttribute IL [in] 한정자를 지정합니다. in 또는 ref readonly 한정자를 사용합니다.
System.Runtime.InteropServices.OutAttribute IL [out] 한정자를 지정합니다. out 한정자를 사용합니다.
System.Runtime.CompilerServices.SpecialNameAttribute IL specialname 한정자를 지정합니다. 컴파일러는 필요한 메서드에 대해 이 한정자를 자동으로 추가합니다.
System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute 이 특성은 delegate* 기능에 필요합니다. 컴파일러는 사용이 필요한 모든 delegate*에 그것을 추가합니다. 그러나 해당 메서드가 함수 포인터에 할당된 경우 메서드 선언에 이 특성을 추가해야 합니다.

다음 특성은 일반적으로 C# 원본에서 허용되지 않습니다. 리플렉션을 사용하는 라이브러리 작성자를 돕고 동일한 정규화된 이름으로 사용자 지정 특성을 만들지 않도록 하기 위해 여기에 나열됩니다.

속성 코멘트
System.Runtime.CompilerServices.CompilerFeatureRequiredAttribute 다운레벨 컴파일러가 안전하게 이해할 수 없는 메타데이터를 사용하지 못하도록 합니다.
System.Runtime.CompilerServices.DecimalConstantAttribute const decimal 필드를 인코딩합니다. 런타임은 decimal 값을 상수 값으로 지원하지 않습니다.
System.Reflection.DefaultMemberAttribute System.Runtime.CompilerServices.IndexerNameAttribute사용하여 인덱서를 인코딩합니다. 이 속성은 그 이름이 Item과 다른 경우 기본 인덱서를 나타냅니다. 이 특성은 원본에서 허용됩니다.
System.Runtime.CompilerServices.DynamicAttribute 서명의 형식이 dynamic(object)인지 여부를 인코딩합니다.
System.Runtime.CompilerServices.ExtensionAttribute 이 특성은 확장 메서드를 적어 줍니다. 또한 컴파일러는 이 특성을 포함하는 클래스에 배치합니다.
System.Runtime.CompilerServices.FixedBufferAttribute 이 특성은 fixed 구조체 필드를 지정합니다.
System.Runtime.CompilerServices.IsByRefLikeAttribute 이 특성은 ref 구조체를 지정합니다.
System.Runtime.CompilerServices.IsReadOnlyAttribute 이 특성은 매개 변수에 in 한정자가 있음을 나타냅니다. in 매개 변수를 readonly ref이나 [In] ref와 구분합니다.
System.Runtime.CompilerServices.RequiresLocationAttribute 이 특성은 매개 변수에 readonly ref 한정자가 있음을 나타냅니다. 이는 readonly refin이나 [In] ref와 구분합니다.
System.Runtime.CompilerServices.IsUnmanagedAttribute 이 특성은 형식 매개 변수에 대한 unmanaged 제약 조건을 지정합니다.
System.Runtime.CompilerServices.NullableAttribute, System.Runtime.CompilerServices.NullableContextAttribute, System.Runtime.CompilerServices.NullablePublicOnlyAttribute 이러한 특성은 소스 코드에서 nullable 주석을 인코딩합니다.
System.ParamArrayAttribute 이 특성은 배열 매개 변수에서 params 한정자를 인코딩합니다.
System.Runtime.CompilerServices.ParamCollectionAttribute 이 특성은 배열이 아닌 매개 변수에서 params 한정자를 인코딩합니다.
System.Runtime.CompilerServices.RefSafetyRulesAttribute 이 특성은 어셈블리의 ref 안전 주석을 이해하기 위해 필요한 C# 버전을 지정합니다. 참조 안전 규칙은 C#이 새로운 기능을 가져오면서 진화합니다.
System.Runtime.CompilerServices.RequiredMemberAttribute 이 특성은 required 한정자가 멤버 선언에 배치되었음을 나타냅니다. 필수 멤버 언어 기능의 인코딩입니다.
System.Runtime.CompilerServices.TupleElementNamesAttribute 이 특성은 서명에 사용되는 튜플 요소 이름을 인코딩합니다.

또한 컴파일러는 내부적으로 사용되는 다른 특성에 대한 선언을 생성할 수 있습니다. 컴파일러는 고유한 용도로 System.Runtime.CompilerServices 네임스페이스에서 이러한 특성을 생성합니다. 일부는 .NET 런타임 라이브러리에 없습니다. 대신 컴파일러는 특성이 필요한 어셈블리에서 internal 형식 선언에 대한 정의를 합성합니다.