Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

GD0302: 일반 유형 매개변수에는 '[MustBeVariant]' 속성으로 주석을 달아야 합니다.

규칙 ID

GD0302

카테고리

사용례

수정 내용이 중단되거나 중단되지 않음

굽기

기본적으로 활성화됨

es

원인

Variant 호환 유형 <c_sharp_variant_ Compatible_types>`이 예상되는 경우 제네릭 유형 인수에 대해 제네릭 유형이 지정되지만 지정된 제네릭 유형에 ``[MustBeVariant]` 특성으로 주석이 추가되지 않습니다.

설명

일반 유형 매개변수에 [MustBeVariant] 속성으로 주석이 달린 경우 일반 유형은 Variant 호환 유형이어야 합니다. 사용된 유형이 일반 유형이기도 하면 이 일반 유형에도 [MustBeVariant] 속성으로 주석을 달아야 합니다. 예를 들어 일반 Godot.Collections.Array<T> 유형은 Variant로 변환할 수 있는 유형의 항목만 지원하며, 적절하게 주석이 추가된 경우 일반 유형을 지정할 수 있습니다.

public void Method1<T>()
{
    // T is not valid here because it may not a Variant-compatible type.
    var invalidArray = new Godot.Collections.Array<T>();
}

public void Method2<[MustBeVariant] T>()
{
    // T is guaranteed to be a Variant-compatible type because it's annotated
    // with the [MustBeVariant] attribute, so it can be used here.
    var validArray = new Godot.Collections.Array<T>();
}

독립적으로 존재해야 하는 것

이 규칙 위반 문제를 해결하려면 Variant와 호환되어야 하는 일반 형식 인수로 사용되는 일반 형식에 [MustBeVariant] 특성을 추가하세요.

경고를 억제해야 하는 경우

이 규칙에서 경고를 표시하지 마세요. [MustBeVariant] 속성으로 주석이 달린 일반 유형 인수를 포함하는 API에는 일반적으로 값이 엔진에 전달되기 때문에 이 요구 사항이 있습니다. 유형을 마샬링할 수 없으면 런타임 오류가 발생합니다.